Add current date to file name when exporting to Excel

  • Thread starter Thread starter Leanne
  • Start date Start date
L

Leanne

Is there a way to programatically add the current date to a file name when
exporting a query, table, report via a macro?
 
As long as the date does not contain slashes as this would affect the file
path name.
Below is an example of the filename in a TransferSpreadsheet command in a
macro.

="C:\Temp\Test" & Format(Date(),"dd-mm-yyyy") & ".xls"
 
Use something like

"MyFile" & Format(Date, "yyyy\-mm\-dd") & ".txt"

instead of just

"MyFile.txt"
 
Back
Top