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

Open MS Excel file from Access VBA Code??? 2

Status
Not open for further replies.

grobermatic

Technical User
Dec 21, 2002
153
GB
Hi,

My code creates a MS Excel file from a query's results usinq SQL.

I want to give the user the option to open the file I just created from the VBA code.

Any Ideas?

Thanks

Craig
 
If you add a reference to the Microsoft Excel Object Library you can use...

Dim appExcel As New Excel.Application

appExcel.Visible = True
appExcel.Workbooks.Open "C:\Test\Test.xls"

There are two ways to write error-free programs; only the third one works.
 
Hi!

Assuming you capture the path and name of the Excel workbook you create you can use the following:

Dim ExcelBook As Excel.Workbook

Set ExcelBook = Excel.Workbooks.Open(Yourfilenameandpath)
ExcelBook.Application.Visible = True

hth
Jeff Bridgham
bridgham@purdue.edu
 
thanks for the quick responses,

How do I add a reference to the Microsoft Excel Object Library?

I think I need to know this in both cases?


Craig

 
Hi Craig!

In your code window go to Tools/References. In the dialog box will be a list box, scroll down until you find MS Excel and put a check in the box beside the latest version. When you say ok the reference will be added.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top