Today's date as file name .csv in Xl 2007
You didn't say what format you would want the date in (remembering, of
course, that you can't use slashes in a file name) nor whether you were
trying to save a single worksheet or the entire workbook. Assuming you
wanted to only save a single worksheet, you could use this code line to do
what you asked (note that the $ sign on the Date function call is required;
also, change the directory path from my example "d:\temp" to wherever you
actually want to save it at)....
Worksheets("Sheet1").SaveAs "d:\temp\" & Date$ & ".csv", xlCSV
Or you can make your own date format string using the Format function,
something like this...
Worksheets("Sheet1").SaveAs "d:\temp\" & Format(Date, _
"ddmmmyyyy") & ".csv", xlCSV
You may want to look up the SaveAs method in the help files as there are
additional options available.
--
Rick (MVP - Excel)
"LuisE" wrote in message
...
What is the code to save a file as a csv which name is today's date? I'm
using Excel 2007.
Thanks in advance
|