I need to save a file on a daily based, archiving it, based on a filename in cell "Admin!C2" and yesterday's date.
I have the code auto running on the file open, so in the Workbook module i have this code:
And in the module i have this code: (based on another post i found on this site)
Essentially, when the file is first opened for the day, it saves a archived copy. But what we need is only 1 save copy per day, the first one. So if the file is open again, and the a archive then already exists, then do create another archive (or overwrite the archive file).
Thanks for your assistance...
Brian
I have the code auto running on the file open, so in the Workbook module i have this code:
VBA Code:
Private Sub Workbook_Open()
Call DailyArchive
End Sub
And in the module i have this code: (based on another post i found on this site)
Code:
Sub DailyArchive()
Dim newFile As String, fName As String
' Don't use "/" in date, invalid syntax
fName = Range("C2").Value
newFile = fName & " " & Format$(Date - 1, "yyyymmdd")
On Error Resume Next
ChDir _
"C:\01 Admin\02 Test Templates\_Save File Daily\Archive"
ActiveWorkbook.SaveAs Filename:=newFile
End Sub
Essentially, when the file is first opened for the day, it saves a archived copy. But what we need is only 1 save copy per day, the first one. So if the file is open again, and the a archive then already exists, then do create another archive (or overwrite the archive file).
Thanks for your assistance...
Brian
Last edited: