Hi,
Can someone help me to modify below cod in order to save a copy of the file in a different folder?
I tried to change "thisPath" to ' thisPath = ThisWorkbook("C:\Users\mihai4.anghel\Downloads\Proiect PT") but nothing happened.
Can someone help me to modify below cod in order to save a copy of the file in a different folder?
I tried to change "thisPath" to ' thisPath = ThisWorkbook("C:\Users\mihai4.anghel\Downloads\Proiect PT") but nothing happened.
VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Application.EnableEvents = False
thisPath = ThisWorkbook.Path
myName = Left(ThisWorkbook.Name, (InStrRev(ThisWorkbook.Name, ".") - 1))
ext = Right(ThisWorkbook.Name, Len(ThisWorkbook.Name) - InStrRev(ThisWorkbook.Name, "."))
backupdirectory = myName & " backups"
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(ThisWorkbook.Path & "/" & backupdirectory) Then
fso.CreateFolder (ThisWorkbook.Path & "/" & backupdirectory)
End If
T = Format(Now, "yyyymmdd hh mm ss")
ThisWorkbook.SaveCopyAs thisPath & "\" & backupdirectory & "\" & myName & " " & T & "." & ext
Application.EnableEvents = True
End Sub