How to use a macro to run a make table query and export to excell

V

Veli Izzet

Hi,

I want to use a button on a form that runs a make-table query, and
exports that table to an excell spreadsheet (including the date in the
name of the spreadsheet)

Thanks for answers
 
F

fredg

Hi,

I want to use a button on a form that runs a make-table query, and
exports that table to an excell spreadsheet (including the date in the
name of the spreadsheet)

Thanks for answers
You can use the TransferSpreadsheet method.
Look it up in VBA help for the various arguments.

To include the date in the spreadsheet's name, you can use something
like this:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97,
"QueryName", "C:\FolderName\SpreadsheetName" & Format(Date,
"mmm-dd-yyyy") & ".xls"

It will create a new Workbook, i.e. "SalesDataAug-14-2005".
The worksheet name will be "QueryName".
 
D

Douglas J Steele

Use the TransferSpreadsheet method, specifying the query (rather than the
table) and the filename (using Format(Date, "yyyymmdd") to include the date
in its name)
 
Top