Backup - Date Included in file name - Macro

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
 
M

mark

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
 
C

CB

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
 
D

Dave Peterson

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.)
 

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