Sub export_to_excel()
Dim mfile
myfile = "Your path name/spreadsheet name.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "your query name", myfile
End Sub()()
Option 2
Use the Transferspreadsheet action in a macro - Although I think this option only allows you to export from a table not a query. I always use option 1.