Export access query to formatted Excel spreadsheet - VBA.

Occasional Contributor


I have a query (qry_myexport) and if I right click it in the navigation pane the option to export it (formatted) to excel is shown.

How can I code a button to do this in VBA?

I have searched extensively and all the VBA codes I’ve found are quite complex.  So I have simply been Right Clicking the query and exporting it that way.  But surely there must be a simple way to do this with VBA.

Thank you

2 Replies
I worked it out
I just did the right click export, then saved the export with a name “export_to_excel”
Then added a button with this
DoCmd.RunSavedImportExport " export_to_excel "