Bill Joe

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



Re: Visual Studio Tools for Office Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003

Dennis Wallentin

Bill,

Are You using Office 2003 PIA






Re: Visual Studio Tools for Office Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003

Bill Joe

Yes, I am using the Office 2003 PIA. It was installed with Office 2003 when I selected Excel/.Net Programmability Support during the installation. As I mentioned, it works fine from the VS2005 development environment but not when I try to the run the compiled code, i.e., the .exe file.

Bill





Re: Visual Studio Tools for Office Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003

Dennis Wallentin

Bill,

Did You manage to solve it If not then You may check out that there exist no local copy of PIA for Excel 2007 in the debug folder for the project.






Re: Visual Studio Tools for Office Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003

Bill Joe

I did not solve it yet, ugh!

There is no local copy of the PIA for Excel 2007 and there shouldn't be because I uninstalled Office 2007 before installing Office 2003. There is a local copy of the PIA for Excel 2003 (Microsoft.Office.Interop.Excel.dll Version 11.0.5530) in bin/debug.

I also tried it with a local copy of each reference listed in my VS2005 IDE but it still doesn't work.

Thanks for response.

Frustrated Bill





Re: Visual Studio Tools for Office Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003

Dennis Wallentin

Bill,

Sorry to hear that the issue still exist. Do You get the same error if You create a new simple test project If not then I believe .NET have not been able to resolve the change from 2007 to 2003 for the specific project.






Re: Visual Studio Tools for Office Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003

Bill Joe

I buillt a new simple test project and I still have the same problem. Thank you for the suggestion.

I believe the problem might be somewhere in the windows registry that resulted from the Office 2007 uninstall not completely removing all its registry entries or restoring the registry to its preinstalled state. I've snooped around the registry and tried deleting keys related to Office interface types but to no avail.

Doesn't anyone from Microsoft look at these forums so they can help out their customers I don't know how to get technical support from Microsoft without calling the pay-for tech support phone number or renewing my MSDN membership (big bucks).

Bill





Re: Visual Studio Tools for Office Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003

Dennis Wallentin

Bill,


Doesn't anyone from Microsoft look at these forums so they can help out their customers

They do but since this forum explicit target VSTO technology You may not expect to get an answer from MSFT. Automation of Office programs tend to be 'between' different forums that target .NET, Office etc.

From my point of view it seems to be a 'blackbox' case which makes it very difficult to solve and I'm not sure it's recommended to switch from 2007 to 2003. I don't like to recommend re-install all the softwares etc but it may be the only way in this case.






Re: Visual Studio Tools for Office Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003

Bill Joe

How can I not switch from Office 2007 to 2003 If I build my application with Office 2007 it won't work on machines with Office 2003, but if I build my application on a machine with Office 2003 it will work on a machine with Office 2003 or 2007. So, if I stay with Office 2007, I would have to use two development machines, one with Office 2007 and one with Office 2003 unless someone has a suggestion to avoid this dilemma.

Thanks for your help.

Still Frustrated Bill





Re: Visual Studio Tools for Office Problem with Interop.Excel after uninstalling Office 2007 and installing Office 2003

Rob van Meeuwen

Hi Bill,

We got the same problem.
My colleague worked on a PC with Office 2003
I am working on a PC with (only) Office 2007.
We both using Visual Studio 2005 (SP1)
We both are working on the same project.

To solve this problem we discover the following way through:

During debugging, my colleague got's his "Interop.Excel.dll" file (from Excel 2003) in the debug folder.
I took a copy of this dll and place it in the projectfolder. I removed all Office200x references in the project and add a reference to the "Interop.Excel.dll".

Note: use the following imports-statement in this case: Imports Excel

For us, this solved the problem.
Suc6,

Rob