Forum Discussion
karenlorr_uk
Apr 06, 2021Copper Contributor
Export access query to formatted Excel spreadsheet - VBA.
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
Sort By
- Have you looked into the DoCmd.TransferSpreadsheet code?
See https://docs.microsoft.com/en-us/office/vba/api/access.docmd.transferspreadsheet- karenlorr_ukCopper ContributorI 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 "