Add current date to file name when exporting to Excel

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?
 
R

RonaldoOneNil

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"
 
D

Douglas J. Steele

Use something like

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

instead of just

"MyFile.txt"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top