Opening an Excel file from Access

T

Tamer Seoud

I created a user interface to view and print out reports.
One of reports needed to be viewed in Excel. I need to
open the excel sheet and output the query result from a
command's event click. The code I used returns error
message. Please advise. Thanks a million

The following is the code I used

Private Sub lbl_OpenSE_Rpt_Click()
Dim ExcelObj As Object
Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.spreadsheet.Open "F:\ExcelTest.xls"
DoCmd.OutputTo acQuery, "qry_SE_Info", "MicrosoftExcel
(*.xls)", "F:\ExcelTest.xls", False, ""
 
E

Ed

I tried just following line. It works fine. It creates a
new file though.

DoCmd.OutputTo acQuery, "RohToolingTimeExcel_qry",
acFormatXLS, "F:\ExcelTest.xls", -1
 
N

nathan harrison

hi tamer,

i think you would need to use: DoCmd.TransferSpreadsheet method. This will
output your query to a predefined spreadsheet.

something like:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "dalequery",
"C:\temp\lisa.xls"

This would transfer the dalequery to the lisa spreadsheet.

other than that, another way would be to finish calling the excel object
model. more complicated but doable....

HTH

Nathan
Software Test Lead
www.skylineprints.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top