![]() |
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 |
Problem opening Excel spreadsheeet
The change turned out to be that I had defined oWB as Excel.Workbooks instead
of Excel.Workbook. Once I made that change all was good. -- Bettie "BGCSOCAL" wrote: 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 |
All times are GMT +1. The time now is 03:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com