Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

Improved MAcro of existing Macro - simple

$
0
0

Hi

I have a macro being used in a file as below

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim sFileName As String
    Dim sDateTime As String

    With ThisWorkbook
        sDateTime = " (" & Format(Now, "yyyy-mm-dd hhmm") & ").xlsm"
        sFileName = Application.WorksheetFunction.Substitute _
          (.FullName, ".xlsm", sDateTime)
        .SaveCopyAs sFileName
    End With
End Sub

It creates a nice backup file with time stamp but in the SAME FOLDER.

I want to change the folder path, how to do that?


Dhaval Paun


Viewing all articles
Browse latest Browse all 11829

Trending Articles