I have an excel that each time I save one more file is saved separately with the name of the respective file, to which is added the date and time of the save in the file name.
I use the macro below for this.
The same thing I would like to do for a word file, but I can't.
Please help.
Thanks.
Option Explicit
Private Sub Workbook_Open()
Application.Caption = "Microsoft Excel AutoBackup"
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Debug.Print Split(ThisWorkbook.Name, ".")(1)
Dim MyFilePath$, Extension$
MyFilePath = ("C:\Documents\Backup\")
Extension = Left(ThisWorkbook.Name, Len _
(ThisWorkbook.Name) - 4) & " Backup"
On Error Resume Next '<< folder exists
MkDir MyFilePath & Extension '<< create folder
'save current version of this book in the folder
ActiveWorkbook.SaveCopyAs Filename:=MyFilePath & _
Extension & "\" & Extension & _
(Format(Now, " yyyy-MM-dd, HH.mm.ss.")) & _
Split(ThisWorkbook.Name, ".")(1)
End Sub
Bookmarks