View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
BGCSOCAL BGCSOCAL is offline
external usenet poster
 
Posts: 4
Default Problem opening Excel spreadsheeet

I'm running VS 2005, Office 2003 tools and Office 2003 on Vista.
I'm having a problem opening an Excel 2003 spreadsheet using the following
code:
'try to open the spreadsheet
Try
oXL = CreateObject("Excel.Application")
oXL.Visible = True
oWB = oXL.Workbooks.Open("c:\Trash\GL Events (3004 items).XLS")
indExcel = True
Catch myException As Exception
'If cannot connect to spreadsheet, then show error
MsgBox("Access to Spreadsheet failed.", MsgBoxStyle.Exclamation,
myException.Message)
indExcel = False
GoTo Close
End Try

Excel starts and the spreadshet loads and then I get an error: Unable to
cast COM object of type Microsoft.Office.Interop.Excel.Workbookclass.

I haven't touched any programming for the last 3 years so I am deficient.
If some one can help me, I would appreciate it.

I was thinking that the fact that Office 2007 had previously been installed
on this PC might be the problem. From my research I can see that the two
together is a no no and that Office 2007 un-install may not be cleaning up
after itself enough. could this be the problem?
--
Bettie