Excel 2002 (10.6789.6735) SP3 Macro

T

Two-Canucks

I have a macro that makes a backup when it saves the active workbook.
On subsequent runs of the macro, the file - Backup of ! Jagerxxx V1.0.xlk is
NOT overwritten! As a result I do not have a backup of the most current file.

I would like to either:
a: overwrite the previously created Backup - or
b: Delete the backup workbook in the macro before recreating it again.

This is the statement I use to save the workbook:

ActiveWorkbook.SaveAs Filename:= _
"D:! Jagerxxx V1.0.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="" _
,ReadOnlyRecommended:=False _
, CreateBackup:=True

Many Thanks
 
T

Tom Ogilvy

On Error Resume Next
Kill BackupFilename
On Error goto 0

'now
ActiveWorkbook.SaveAS . . .
 
T

Tom Ogilvy

I don't use that feature, but after doing some testing, I believe this
option just saves the previous copy of the workbook as a back up - not the
latest copy . This appears to be different from what you want. Perhaps you
want to use (make sure you uncheck create backup option in the saveas
dialog).

s = "! Jagerxxx V1.0.xls"

Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAS "D:\Backup Copy of " & s
Application.DisplayAlerts = True
ActiveWorkbook.Save Filename:=s

Since this isn't the first save of the workbook and you not changing names,
use Save rather than SaveAs.
 
T

Two-Canucks

I used the Kill feature, have tested it, and it works as I requested.
Thanks Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top