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

B

Bill F

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.get_Workbooks()
at RunExcel.Form1.btnRunOutsideForm_Click(Object sender, EventArgs e) in
D:\FMI\Dev\NetPlay\VS2005\RunExcel2003\RunExcel\Form1.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
 
J

Jim Cone

Bill,
Try removing the parentheses after .add
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Bill F" <[email protected]>
wrote in message
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.get_Workbooks()
at RunExcel.Form1.btnRunOutsideForm_Click(Object sender, EventArgs e) in
D:\FMI\Dev\NetPlay\VS2005\RunExcel2003\RunExcel\Form1.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
 
B

Bill F

I tried removing the parentheses after the .Add but this did not solve the
problem.

Thanks for the suggestion.

Major Frustrated Bill
 
Joined
Apr 30, 2010
Messages
4
Reaction score
0
I am having the same issue. I have both MS Excel 2003 and Office 2007 on the same machine. I have tried repairing the Excel 2003 installation and uninstalling and reinstalling it with no resolution. I had to install Excel 2003 because the machines I am developing this application for all have Office 2003. If I install VS 2010 on another machine with only Office 2003 on it, I have no issues. I had another application where I was also exporting to Excel 2003 and had no issues. This leads me to believe there may have been a Microsoft update that has caused this issue as the original application now has the same issue. I saw a post where someone else referenced this, but thanks to them, they failed to reference the KB in order for other to validate this was in fact the issue.
 
Joined
May 10, 2012
Messages
1
Reaction score
0
Did you find a solution to this problem? I have the exact same problem, and cant find a solution :blush:

/Jakob

I am having the same issue. I have both MS Excel 2003 and Office 2007 on the same machine. I have tried repairing the Excel 2003 installation and uninstalling and reinstalling it with no resolution. I had to install Excel 2003 because the machines I am developing this application for all have Office 2003. If I install VS 2010 on another machine with only Office 2003 on it, I have no issues. I had another application where I was also exporting to Excel 2003 and had no issues. This leads me to believe there may have been a Microsoft update that has caused this issue as the original application now has the same issue. I saw a post where someone else referenced this, but thanks to them, they failed to reference the KB in order for other to validate this was in fact the issue.
 
Joined
Apr 30, 2010
Messages
4
Reaction score
0
No, I have not. I simply just moved and compiled the application on a VM that only had VS 2010 and Office 2003 on it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top