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

open an Excel file in Word VB Editor

Status
Not open for further replies.

Krispy2293

Technical User
Jan 13, 2003
4
0
0
US
I am trying to open a certain Excel file using VB editor in Word. I have used the Shell function to open Excel, but am having trouble opening the spreadsheet. Does anyone know how to do this?

Thanks!
 
I am not sure this will help but from a .net application, one does the following:

dim xlApp As Excel.Application
dim xlBook As Excel.Workbook

public sub OpenXLBook(optional filename as string="",optional visible as boolean=true)
if (xlApp is nothing) then
xlApp = new Excel.ApplicationClass()
endif
if (filename.trim.length=0) then
xlBook=xlApp.Workbooks.Add() ' opens new blank book
else
xlBook=xlApp.Workbooks.Open(filename) ' opens given name
endif
xlApp.visible = visible
end sub

caveat, catch and show errors if possible. also, check whats running when you are thru xlApp.Quit() as you may have to add GC (garbage collection) to clean up memory when through.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top