Hi,
This code will do it for you.
Design a new module (or manipulate this with Private Subs instead of Functions and place in your form) and copy/paste this into it. Change qryTestPlease to your query or table that you are trying to export. And change C:\Testplease.xls to your spreadsheet that you export to and that you want to open.
Function SpreadSheet()
Dim gsSpreadSheet As String
Dim successful
DoCmd.TransferSpreadsheet acExport, 8, "qryTestPlease", "C:\testplease.xls", True, ""
gsSpreadSheet = "C:\testplease.xls"
successful = Shell("C:\Program Files\Microsoft Office\Office\excel.exe " & _
Chr$(34) & gsSpreadSheet & Chr(34), vbMaximizedFocus)
End Function
Save it as mdlSpreadSheet (or whatever)... Now just call the function whenever you want it to run.
-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
------------------