Automatic backup in Excel?

D

David Biddulph

In Word one can set up so that when saving any file a backup is
automatically saved.
With Excel one can include a backup as one of the options under "Save As"
for for any individual file, but is there any way to set this as a default
for all files?
 
A

Andy

With Excel one can include a backup as one of the options under
"Save As" for any individual file, but is there any way to set
this as a default for all files?

This macro copies the OriginalFile to OriginalFile.baq and then saves
the modified file. It does nothing if the file hasn't been
modified, and uses the Save As dialog if it's a new file.

Put it in personal.xls; you have to have Microsoft Scripting
Runtime activated in VBA, with "VBA PROJECT (PERSONAL.XLS)" selected.

I have it assigned to Ctrl-S and also to a toolbar button.

I'm not well versed in VBA. This may be crude but I stopped
messing with it as soon as it worked.

====================================

Sub BackupAndSave()

'Must have Tools>Reference>MicrosoftScriptingRuntime checked

Dim strFileA As String
Dim strFileB As String
Dim strFileC As String
Dim strFileD As String

Dim fs As Scripting.FileSystemObject
Set fs = New Scripting.FileSystemObject
strFileA = ActiveWorkbook.FullName
strFileB = strFileA & ".baq"
If Not fs.FileExists(strFileA) Then
strFileC = Application.GetSaveAsFilename
strFileD = strFileC & "xls"
ActiveWorkbook.SaveAs Filename:=strFileD

Else
If ActiveWorkbook.Saved = False Then fs.CopyFile strFileA, strFileB
If ActiveWorkbook.Saved = False Then ActiveWorkbook.Save
End If

End Sub

====================================
 
Top