Posted to microsoft.public.excel.programming
|
|
Backup with date-time
You may want to post the code you used if Bob's answer didn't help. His code
worked fine for me after I saved the test workbook once.
But I did have to change the last line to:
Application.DisplayAlerts = True
appeng wrote:
Still comes up with comply error "expected: end of statement" and highlights
Filename
Art
"Bob Phillips" wrote:
How about this
Application.DisplayAlerts = False
With ActiveWorkbook
.SaveCopyAs Filename:="c:\temp\" & _
Left(.Name, InStr(1, LCase(.Name), ".xls") - 1) & _
Format(Now, "mmddyyhhmmAMPM") & ".xls"
End With
Application.Display = True
--
HTH
RP
(remove nothere from the email address if mailing direct)
"appeng" wrote in message
...
Bob,
Thank you! I am having a complie error. It does not like
FileName:=
But I am still working on it. I believe that is is domething simple, but
not
having a lot of VBA knowledge . . .
Art
"Bob Phillips" wrote:
Does this work
Sub Save_Workbook()
Application.DisplayAlerts = False
With ActiveWorkbook.
SaveCopyAs FileName:= "c:\temp\" & _
Left(.Name, InStr(1, LCase(ThisWorkbook.Name), ".xls") - 1) & _
Format(Now, "mmddyyhhmmAMPM") & ".xls"
End With
Application.Display = True
End Sub
--
HTH
RP
(remove nothere from the email address if mailing direct)
"appeng" wrote in message
...
I am using MS Excel 97 and trying to save a backup copy of files, with
date
and time saved, to a specific directory while maintaining the original
file
name for the active workbook. For example
Original workbook 1 name = c:\data\schedule.xls
Original workbook 2 name = c:\data\data.xls
When saved, save a copy in c:\temp
With file name schedule NOV0504 623AM.xls
Or data NOV404 703PM.xls
The original file would remain
c:\data\schedule.xls and c:\data\data.xls
I have tried the following but cannot get it to work
Sub Save_Workbook()
Application.DisplayAlerts = False
ActiveWorkbook.SaveCopyAs FileName:= _
"c:\temp\" & _
Left(ThisWorkbook.Name, InStr(1, LCase(ThisWorkbook.Name), ".xls") -
1) _
& Format(Date, "mmddyy") & Format(Date, "hhmmAMPM") & ".xls"
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.DisplayAlerts = True
End Sub
I am sure I am missing something simple. Any suggestions?
--
Dave Peterson
|