Creating a command to export records from a table to an Excel spreadsheet

I would like to create a menu command that will export the records output from a query into an Excel spreadsheet. Currently this is accomplished by clicking on the "External Data" tab and selecting the "Excel" option (see attached). However, for the convenience of the user (who is not Access savvy),  I would like to create a command button in the menu that will accomplish the same thing. How would I do it?
geeta_m9Asked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
you can also use

DoCmd.OutputTo acOutputTable, "tableName", acFormatXLSX, "c:\folder\Myexcel.xlsx", True


<What is the "10" parameter for? >
that is the excel format for A2007 and above

if you are using Excel2003, use

docmd.transferspreadsheet acexport,8, "tablename","c:\folder\myexcel.xls", true
0
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
use this code

docmd.transferspreadsheet acexport,10, "tablename","c:\folder\myexcel.xlsx", true
0
 
geeta_m9Author Commented:
What is the "10" parameter for?
0
 
geeta_m9Author Commented:
I just tested it and it works great!

Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.