Throwaway8843
New Member
- Joined
- Jun 29, 2021
- Messages
- 13
- Office Version
- 365
- Platform
- Windows
Look I am sure this question has been asked and I have found some close answers online but I am having an issue.
When I run this code it saves the backup in the personal workbooks filepath rather than the in the filepath of the current excel I am using. Is there any way to change that while keeping the file location dynamic?
VBA Code:
Sub FileBackUp()
' Saves a backup copy of the excel document in the same folder with the current date and name of the file.
Dim saveDate As Date
Dim formatDate As String
Dim backupFolder As String
saveDate = Date
formatDate = Format(saveDate, "DD - MM - YYYY")
Application.DisplayAlerts = False
backupFolder = ThisWorkbook.Path & "\"
ActiveWorkbook.SaveCopyAs Filename:=backupFolder & Replace(ActiveWorkbook.Name, ".xlsm", "") & " " & formatDate & ".xlsm"
Application.DisplayAlerts = True
MsgBox "Backup Successfully In The Path " & backupFolder
End Sub
When I run this code it saves the backup in the personal workbooks filepath rather than the in the filepath of the current excel I am using. Is there any way to change that while keeping the file location dynamic?