Export a report to Excel using a button

  • Thread starter Thread starter Jen
  • Start date Start date
J

Jen

Hi,
Can somebody show an example on how to create a button
that can export a report to a Excel file in a specified
folder?
Thanks,
Jen
 
The "trick" is to use the button's OnClick event to run code or a macro that
does the TransferSpreadsheet action. This will export to EXCEL from a query
or table, so you would use the query that is the record source of the report
that you want to "export".

Put a button on the form, and attach code similar to this to the button's
OnClick event:

Private Sub cmdButtonName_Click()
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
"TableQueryName", "PathAndFileName"
End Sub
 
Hi Ken,
Thank you very much for your help.
When I used the following method on the click event, I
got the following message: Couldn't find installable
ISAM. Is there any idea why and how can I solve it?
thanks,
Jen
 
Back
Top