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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export query to Excel

Status
Not open for further replies.

Zonie32

Technical User
Jan 13, 2004
242
US
I have a simple query as a command button. I just want to be able to click the button and have the query open in Excel 2003 format.

Anyone have an easy solution? Thanks in advance!
 
The docmd will export the data to an excel file.
The Follow Hyperlink will open up the excel file.

Code:
...
...
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "QUERYNAME", "c:\temp\EXCELNAME.xls", True

    FollowHyperlink "c:\temp\EXCELNAME.xls", , True, False
...
...
 
Thanks for the tip. In the past I've done this the hard way by creating an Excel object:

Code:
    Set gobjExcel = CreateObject("Excel.Application")
    gobjExcel.Workbooks.Open Filename:="EXCELNAME.xls"
    gobjExcel.Visible = True

I'll try FollowHyperLink next time.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top