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

Open existing excel as excel object 1

Status
Not open for further replies.

dbsquared

Programmer
Nov 7, 2002
175
US
I am having trouble opening an excel file can I get some help.

Here is what I have coded
dim xltemp as Excel.Application
xltemp = GetObject("c:\data\Reports\Switch1.xls, "Excel.Application")
I get a unknown file name or classname error

if I do
dim xltemp as object
xltemp = GetObject("c:\data\Reports\Switch1.xls)
it opens the file but I get none of excels options for going through the file.
i.e. xltemp.cells(1,1).value
I get errors here

Thanks for your help

To go where no programmer has gone before.
 
Hi, hope this helps:
Dim xlapp As Excel.Application
Dim xlbook1 As Excel.Workbook
xlapp = CType(CreateObject("Excel.Application"), Excel.Application)
xlbook1 = CType(xlapp.Workbooks.Open("c:\data\Reports\Switch1.xls"), Excel.Workbook)
 
Worked like a charm thank you my head was getting sore.

To go where no programmer has gone before.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top