Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a date into a saveas filename 1

Status
Not open for further replies.

woodyinoz

IS-IT--Management
Jan 8, 2002
215
GB
Hi all,

I currently use the code below to save an Excel spreadsheet as a csv.

Code:
ActiveWorkbook.SaveAs Filename:= _
    "J:\Projects\Great Plains\POHDR.csv", FileFormat:=xlCSV, _
    CreateBackup:=False

However, a user now requires the file to be saved with todays date added onto the end of the filename.

i.e. POHDR06-02-06.csv

Whats the best way to go about this?

Thanks in advance,

Woody
 
Something like:
Code:
ActiveWorkbook.SaveAs Filename:= _
    "J:\Projects\Great Plains\POHDR" & Format(Date,"dd-mm-yy") & ".csv", FileFormat:=xlCSV, _
    CreateBackup:=False
Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 


When converting a REAL DATE to a STRING, it is often advisable to format the string in priority by YEAR, MONTH & DAY, such as...
[tt]
Format(MyDate, "yyyy-mm-dd")
[/tt]
since other formats that begin with either a month or a day will not colate as expected.

Skip,

[glasses] [red]Be Advised![/red] Dyslexic poets...
write inverse! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top