A
AA
Sub xBackupAndSave()
'copies the OriginalFile to OriginalFile.baq
'then saves the Edited file
On Error Resume Next
Dim strFileA, strFileB
Dim fs As Scripting.FileSystemObject
Set fs = New Scripting.FileSystemObject
strFileA = ActiveDocument.FullName
strFileB = strFileA & ".baq"
fs.CopyFile strFileA, strFileB
With Options
.CreateBackup = False
End With
ActiveDocument.Save
With Options
.CreateBackup = True
End With
End Sub
My Backup macro has been working well.
I put in "On Error Resume Next" so I could use it to save a new
document without it stopping at "fs.CopyFile strFileA, strFileB"
because strFileA doesn't exist yet. (I'd welcome a less crude method).
I didn't need an extra "Backup of FirstPartOfFilename.wbk" so I turned
that off just before saving the current file and then turned it back
on so I have a backup if I use the regular Save command.
I need one further enhancement:
Is there a way for VBA to test if the current file has been edited
after it's been opened so I can exit the macro if the file hasn't been
changed?
If I haven't changed the file and I run the macro, it still copies
strFileA to strFileB, giving me a backup file identical to the current
file, so I lose an iteration unnecessarily.
Andy
'copies the OriginalFile to OriginalFile.baq
'then saves the Edited file
On Error Resume Next
Dim strFileA, strFileB
Dim fs As Scripting.FileSystemObject
Set fs = New Scripting.FileSystemObject
strFileA = ActiveDocument.FullName
strFileB = strFileA & ".baq"
fs.CopyFile strFileA, strFileB
With Options
.CreateBackup = False
End With
ActiveDocument.Save
With Options
.CreateBackup = True
End With
End Sub
My Backup macro has been working well.
I put in "On Error Resume Next" so I could use it to save a new
document without it stopping at "fs.CopyFile strFileA, strFileB"
because strFileA doesn't exist yet. (I'd welcome a less crude method).
I didn't need an extra "Backup of FirstPartOfFilename.wbk" so I turned
that off just before saving the current file and then turned it back
on so I have a backup if I use the regular Save command.
I need one further enhancement:
Is there a way for VBA to test if the current file has been edited
after it's been opened so I can exit the macro if the file hasn't been
changed?
If I haven't changed the file and I run the macro, it still copies
strFileA to strFileB, giving me a backup file identical to the current
file, so I lose an iteration unnecessarily.
Andy