Date in File Name

RaunLGoode

Registered User.
Local time
Today, 05:36
Joined
Feb 18, 2004
Messages
122
I have a report generated in Excel. I would like to Save the report as "Employee Name-Date", using the following code:

ActiveWorkbook.SaveAs Filename:= _
"\\[Path]\" & CName & "-" & WEDate & ".xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

When I try th execute the code I get an error. When I remove the Date Variable (In Red) the code runs with no error. I suspect the problem lies in the date data type of the date variable. There must be a way to modify the variable so I can use it as part of the file name. Could somebody give me some help?
 
Would this work?
Code:
ActiveWorkbook.SaveAs Filename:= _
"\\[Path]\" & CName & "-" [COLOR=red]& Str(WEDate) [/COLOR]& ".xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
 
Error persists

Unfortunately, I get the same error. Any other suggestions
I am using Excel 2003 /Win XP
 
maybe it doesn't like the slashes? (i am assuming you are using mm/dd/yy, or similar.) see if it will work if you play with the date format, eg use mm-dd-yy, or even better custom mmddyyyy or similar.
just an idea.
l
 

Users who are viewing this thread

Back
Top Bottom