Created
June 10, 2019 08:58
-
-
Save DataSolveProblems/1e1efc8cfc85ef2a28d93e660a60b64f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) | |
Call Save_Backup("<Your Backup Folder Directory>") | |
End Sub | |
Sub Save_Backup(ByVal Backup_Folder_Path As String) | |
Dim fso As Object | |
Dim ExtensionName As String, FileName As String | |
Dim wbSource As Workbook | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set wbSource = ThisWorkbook | |
ExtensionName = fso.GetExtensionName(wbSource.Name) | |
FileName = Replace(wbSource.Name, "." & ExtensionName, "") | |
fso.CopyFile ThisWorkbook.FullName, _ | |
fso.BuildPath(Backup_Folder_Path, FileName & " (" & Format(Now(), "mm-dd-yy hhmmssAM/PM") & ")." & ExtensionName) | |
Set fso = Nothing | |
Set wbSource = Nothing | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment