ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filename with current Date() (https://www.excelbanter.com/excel-programming/287078-filename-current-date.html)

Graham[_5_]

Filename with current Date()
 
Its probably a format problem (filenames don't like '/'
etc.

Try using "C:\Data_" & Format(Date, "mmddyy")

instead of "C:\Data_"&Date()&".xls"

Cheers,

Graham

-----Original Message-----
Hi All,

I am trying to compile a simple procedure that will name
and save the current workbook with a filename that
includes the system date. But my code is generating a
compile error, please can you review below and let me

know
where I am going wrong? thanks,

===

ChDir _
"C:\"
ActiveWorkbook.SaveAs Filename:= _
"C:\Data_"&Date()&".xls" _
, FileFormat:=xlNormal, Password:="",
WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close

===
.


toothfish__

Filename with current Date()
 
thanks Graham, works perfectly.
-----Original Message-----
Its probably a format problem (filenames don't like '/'
etc.

Try using "C:\Data_" & Format(Date, "mmddyy")

instead of "C:\Data_"&Date()&".xls"

Cheers,

Graham

-----Original Message-----
Hi All,

I am trying to compile a simple procedure that will name
and save the current workbook with a filename that
includes the system date. But my code is generating a
compile error, please can you review below and let me

know
where I am going wrong? thanks,

===

ChDir _
"C:\"
ActiveWorkbook.SaveAs Filename:= _
"C:\Data_"&Date()&".xls" _
, FileFormat:=xlNormal, Password:="",
WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close

===
.

.



All times are GMT +1. The time now is 11:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com