By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003

P: n/a
I am developing a VB.Net application with VS 2005 that opens an Excel
workbook and populates the worksheet with data. I started developing the
application with Office 2007 installed on my Vista OS, but after I
discovered that it won't run on a system with Office 2003, I uninstalled
Office 2007 and installed Office 2003. I reset the reference in .Net to the
Microsoft Excel 11.0 Object Library. The application works fine from the
..Net IDE but when I compile and run the .Exe I get the following error
message:

************** Exception Text **************
System.InvalidCastException: Unable to cast COM object of type
'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type
'Microsoft.Office.Interop.Excel._Application'. This operation failed because
the QueryInterface call on the COM component for the interface with IID
'{000208D5-0000-0000-C000-000000000046}' failed due to the following error:
could not be found. (Exception from HRESULT: 0x80030002
(STG_E_FILENOTFOUND)).
at Microsoft.Office.Interop.Excel.ApplicationClass.ge t_Workbooks()
at RunExcel.Form1.btnRunOutsideForm_Click(Object sender, EventArgs e) in
D:\FMI\Dev\NetPlay\VS2005\RunExcel2003\RunExcel\Fo rm1.vb:line 22
at System.Windows.Forms.Control.OnClick(EventArgs e)

This did not occur with the original Office 2007 installation. I've tried
running Office repair, uninstalling and reinstalling Excel .Net program
support from the Office installation, but none of this works. The exe works
on my test platform running WinXP and Office 2003 (clean installation where
Office 2007 was never installed).

It makes no difference whether Option Strict is on or off. The code is
simple:

Dim excelApp As Excel.Application = New Excel.Application
MessageBox.Show("After Dim excelApp As Excel.Application = New
Excel.Application")

Dim Wbk As Excel.Workbook
MessageBox.Show("After Dim Wbk as Excel.Workbook")

Wbk = excelApp.Workbooks.Add()
MessageBox.Show("After Wbk = excelApp.Workbooks.Add()")

excelApp.Visible = True
MessageBox.Show("After excelApp.Visible = True")

It bombs at Wbk = excelApp.Workbooks.Add(). I've tried using
ApplicationClass and CreateObject but none of that works either.

Anyone know how to fix this short of reinstalling the entire operating
system?

Thanks,

Bill
Apr 29 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.