Hi,
I am an absolute beginner in VBA, and have stumbled across it because of G. Mayor's addin for auto saving active word files. (
The add-in at that site can auto-save open word files at a user defined interval. Another add-in he provides, can backup the current file to a user specified location. However, I am interested in a macro, which will not only auto-save, but also immediately backup the file with a date/time stamp in a user-defined folder.
I have been trying to create a macro but have been unsuccesful in getting it to work, and was wondering it the more experienced users here can help me out.
This is the macro, which I have created, and which does not work:
Sub FileBackupSave()
Dim strDocName As String
Dim strWordBackupDoc As String
Dim strMyBackupDoc As String
Options.CreateBackup = True
ActiveDocument.Save
ActiveDocument.Saved = False
ActiveDocument.Save
strDocName = ActiveDocument.FullName
strWordBackupDoc = ActiveDocument.Path & "\Backup of " & ActiveDocument.FullName
strMyBackupDoc = ActiveDocument.Path & "\Backup of " & Format(Date, "yyyy-mm-dd") & _
" " & Format(Time, "hh-mm-ss AMPM") & ActiveDocument.FullName
FileCopy strWordBackupDoc, strMyBackupDoc
End Sub
Thanks,
Sam
I am an absolute beginner in VBA, and have stumbled across it because of G. Mayor's addin for auto saving active word files. (
The add-in at that site can auto-save open word files at a user defined interval. Another add-in he provides, can backup the current file to a user specified location. However, I am interested in a macro, which will not only auto-save, but also immediately backup the file with a date/time stamp in a user-defined folder.
I have been trying to create a macro but have been unsuccesful in getting it to work, and was wondering it the more experienced users here can help me out.
This is the macro, which I have created, and which does not work:
Sub FileBackupSave()
Dim strDocName As String
Dim strWordBackupDoc As String
Dim strMyBackupDoc As String
Options.CreateBackup = True
ActiveDocument.Save
ActiveDocument.Saved = False
ActiveDocument.Save
strDocName = ActiveDocument.FullName
strWordBackupDoc = ActiveDocument.Path & "\Backup of " & ActiveDocument.FullName
strMyBackupDoc = ActiveDocument.Path & "\Backup of " & Format(Date, "yyyy-mm-dd") & _
" " & Format(Time, "hh-mm-ss AMPM") & ActiveDocument.FullName
FileCopy strWordBackupDoc, strMyBackupDoc
End Sub
Thanks,
Sam