Export to Excel with Automatic Date Name

  • Thread starter Thread starter Dan Galloway
  • Start date Start date
D

Dan Galloway

I have Access 97 building a data table that must be
exported daily as an Excel file to another user. How can
I get Access to automatically name the output .xls file
with today's date, i.e. 071403 or 07-14-03. Ideally, I'd
like to have it use a fixed text name with variable
date: ABC 07-14-03 for example, since I actually output
two .xls spreadsheets, one named ABC (date) and the other
XYZ (date).
 
You can import and export using code like this (change to acExport).

That means you can compute a string for the file name based on Today's date
and use it in your code.

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, strTableName,
strLocalDir & strLocalFileName, True
 
You can tweak and use the below line of code. You would
want to use "Now()" in your filename to get the current
date. ex. Lawmanagerdata & Now() & .txt

DoCmd.TransferText acExportFixed, "New LawManagerData
Export", "Lawmanagerdata", "\\sdxhq-fc1
\HRISLM\Lawmanagerdata.txt"
 
Back
Top