Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting a cross tab query to a spreadsheet.

Status
Not open for further replies.

kkarren

Technical User
Mar 30, 2000
33
US
I have a cross tab query that I would export by code to a spreadsheet replacing the existing spreadsheet each time I use the command button. Then have the spreadsheet show on the screen.
 
Function ExportOpenXls()

Dim gsSpreadSheet As String
Dim successful

gsSpreadSheet = "C:\MyPath\MyXls.xls"

DoCmd.TransferSpreadsheet acExport, 8, "tblMyTableName", gsSpreadSheet, True, ""

successful = Shell("C:\Program Files\Microsoft Office\Office\excel.exe " & _
Chr$(34) & gsSpreadSheet, vbMaximizedFocus)

End Function

The XLS file will be an Excel 97 spreadsheet with FieldName headings. Change your spreadsheet path to the file you are exporting to. Change the table or query name of "tblMyTableName" to your recordsource.

-Josh
------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top