Backup - Date Included in file name - Macro

  • Thread starter Thread starter CB
  • Start date Start date
C

CB

I would like to know how to create a Macro that will do a
File/Save As:

1. Send my new file into another directory
2. A filename, which will include the current date

Is it possible?

Thanks,
CB
 
Is it possible?

definitely.

Try something like this:

Sub save_backup()

'backup directory constant

Const cnDir = "c:\test\"


'save as

ActiveWorkbook.SaveAs cnDir & ActiveWorkbook.Name
& "_" & Format(Date, "mm_dd_yy") & ".xls"

End Sub


You also might want to try the SaveCopyAs method,
depending upon your specific application
 
Hi Mark -

I tried this - but it stops after ActiveWorkbook.Name &
ActiveWorkbook.SaveAs cnDir & ActiveWorkbook.Name
& "_" & Format(Date, "mm_dd_yy") & ".xls"

Thanks for your help,

CB
 
You got hit by linewrap in the newsgroup post.

ActiveWorkbook.SaveAs cnDir & ActiveWorkbook.Name _
& "_" & Format(Date, "mm_dd_yy") & ".xls"

(note the addition of space & underscore on the first line. That means the
logical line is continued on the next physical line.)
 
Back
Top