Export MS Access query into Excel

microsoft access

In Access, I know that there is a "Analyze it with Microsoft Office Excel" option, but i am creating a database and the person requesting this wants a command button on a form to do the same thing that the "Analyze it with Microsoft Office Excel" button does. So my question is can anyone help me write vba code to export a MS Access query into Excel, formatted the exact way the "Analyze it with Microsoft Office Excel" does?

Best Answer

this worked on the Northwinds db:

DoCmd.OutputTo acTable, "Customers", "MicrosoftExcelBiff8(*.xls)", "", False, "", 0

http://msdn.microsoft.com/en-us/library/aa141534(v=office.10).aspx

Related Question