Forum Discussion

Lorenzo Kim's avatar
Lorenzo Kim
Bronze Contributor
Aug 03, 2018

Force a SAVEAS with a designated filename

I have a workbook named "RAD Analysis.xlsm" and I want to force a SAVEAS with a filename as:

"RAD Analysis for the month of August-2018.xlsm"

 

ActiveWorkbook.Name = "RAD Analysis.xlsm"     ** (Read-only) file

Sheets("RAD").Range("A2") = 8/3/2018

 

 

variable declaration - something like...

    Dim nWB = ActiveWorkbook.Name

           ndate = Sheets("RAD").Range("A2") 

   newWBname = WorksheetFunction.left(nWB,len(nWB)-5)  &  Str(Text(ndate,"mmmmmmmm-yyyy))

            I keep getting error on this part.

 

How do I write the vba for this SAVEAS in the workbook_beforeclose or beforesave..

 

many many thanks

 

  • Lorenzo Kim's avatar
    Lorenzo Kim
    Bronze Contributor

    NewWBname = Replace(ThisWorkbook.name, ".xlsm", "") & " for the month of " & _
    Format(Sheets("RAD").Range("A2"), "mmmm-yyyy") & ".xlsm"

    courtesy of Mr. steve the fish

    • Lorenzo Kim's avatar
      Lorenzo Kim
      Bronze Contributor

      The procedure I would like to request is:
      Whenever the user click [X] at the top right or exit the workbook (if there are changes made),
      there should appear a saveas dialog box wherein the default is the above NewWBname (.xlsm)
      If the user tried to use the original name "RAD Analysis" - it should loop again for the default filename.

      this procedure should suppress (if possible) the default save dialog box of excel  otherwise there might be two save boxes appearing one after the other..

      many many thanks

      • Lorenzo Kim's avatar
        Lorenzo Kim
        Bronze Contributor

        The procedure I would like to request is:
        Whenever the user click [X] at the top right or exit the workbook (AND there are changes made), there should appear a SAVEAS Dialog Box wherein the default is the above NewWBname (.xlsm)
        If the user try to SAVE AS the original name "RAD Analysis" - it should loop again for the default filename.

        this procedure should suppress (if possible) the default save dialog box of excel  otherwise there might be two save boxes appearing one after the other..

        many many thanks

Resources