General Ledger
Active Member
- Joined
- Dec 31, 2007
- Messages
- 460
Dear All,
I am looking for VBA to do a Save As on the Excel file and append the current date to the end of the file name.
For example, if the file name is "Accounts Payable" and the current date is 18 July 2011, I would like the Save As file name to be "Accounts Payable 20110718" (YYYYMMDD sequence for the date).
Also, if the user selects Cancel from the Save As dialog box, I do not want the macro to return a Run-Time Error 1004 as it does now. I would like it to cancel the Save As operation and continue on in the macro.
Here is my current code:
I am using Windows 7 and Excel 2010
Thanks,
GL
I am looking for VBA to do a Save As on the Excel file and append the current date to the end of the file name.
For example, if the file name is "Accounts Payable" and the current date is 18 July 2011, I would like the Save As file name to be "Accounts Payable 20110718" (YYYYMMDD sequence for the date).
Also, if the user selects Cancel from the Save As dialog box, I do not want the macro to return a Run-Time Error 1004 as it does now. I would like it to cancel the Save As operation and continue on in the macro.
Here is my current code:
Code:
'Save file
ChDir "Z:\Excel"
ActiveWorkbook.SaveAs Filename:="Z:\Excel\ACCOUNTS PAYABLE.xlsx", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
I am using Windows 7 and Excel 2010
Thanks,
GL