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

Can you Open Microsoft Excel and a spreadsheet file with VB?

Status
Not open for further replies.

dlingo

Programmer
Nov 19, 2001
60
0
0
US
I have used the following code to open Access, export a table into an Excel spreadsheet, and close Access:

Dim ac As Access.Application
Set ac=New Access.Application
ac.OpenCurrentDatabase ("c:\reports.mdb")
ac.DoCmd.TransferSpreadsheet acExport, 8, "TEMP_STAT", "c:\moduletest.xls", False
ac.CloseCurrentDatabase

Is there a way to open Excel with the newly created spreadsheet?
 
dlingo,
you can shell excel in your system. like this

tt = Shell("D:\Program Files\Microsoft Office\Office\excel.exe c:\Whatever.xls", vbMaximizedFocus)

this will open c:\Whatever.xls as excel is opened
you have to put the path of excel.exe as it is in your system.
cheers
 
If you want to use the Excel object library
Code:
Dim xlApp as Excel.Application

Set xlApp = New Excel.Application
Workbooks.Open FileName:="C:\YourPath\YourFile.xls"
Workbooks.Application.Visible = True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top