Microsoft.Office.Interop.Excel Fails

Posted on 2012-08-20
Last Modified: 2012-08-20
I installed the Office 2013 RC and then uninstalled. Now when I run a Windows Application developed in C# using visual studio 2008 I get the following error:

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: Library not registered. (Exception from HRESULT: 0x8002801D

I know the code is correct because I have been using it for a long time and I know the problem is with the Interop.Excel that it is messed up but I don't know how to fix it. I have upgraded excel on my machine from 2003 to 2010 I still have Access 2003 installed and Publisher 2007 along with the Office 2010.
I tried to repair the office installations (2003,2007,2010) and reinstall the PIA for 2003 and 2010 but no luck.
Any help on how to clean the references and make it work will be appreciated.
Question by:ocortesmx
    LVL 43

    Accepted Solution

    I'd suggest de-installing office, running a registry cleaner (there are numbers available on the internet) then reinstalling office.

    Author Comment

    I was checking the GAC and I see the following entries:

    Microsoft.Office.Interop.Excel v.15
    Microsoft.Office.Interop.Excel v.14

    Policy.11.0.Microsoft.Office.Interop.Excel v. 15
    Policy.11.0.Microsoft.Office.Interop.Excel v. 14
    Policy.12.0.Microsoft.Office.Interop.Excel v. 15
    Policy.12.0.Microsoft.Office.Interop.Excel v. 14
    Policy.14.0.Microsoft.Office.Interop.Excel v. 15
    Policy.14.0.Microsoft.Office.Interop.Excel v. 14

    Should I uninstall some of them? I need the application to export to Excel 2003 and above like it was doing before. Actually it still works on the machines that I deploy the application, it is just on my development machine that it stopped working but I am affraid that if I create a new version of the program now that it is not working on my machine the other machines will be confused too.
    Thanks for any help.

    Author Comment

    "I'd suggest de-installing office, running a registry cleaner (there are numbers available on the internet) then reinstalling office."

    Thanks for the suggestion but I will need to uninstall office 2003, 2007, and 2010 and then reinstall them and I am not sure that I want to do that. I am hopping that there is another way to fix the problem.
    LVL 43

    Expert Comment

    I would still recommend doing what I suggested.  You could try deleting things but it might not work or even makes things worse.

    (I know it is a bit late - but trying beta software on your development machine without a complete backup <I'd even say clone the hard disc> is not a good idea).
    LVL 83

    Expert Comment

    What version PIA are you using? 2003? Try just reinstalling 2003.

    Author Closing Comment

    I did the uninstall the used CCleaner to clean the registry and finally started on safe mode and uninstalled all the office entries in the GAC. After I installed office 2003 and everything worked fine then installed office 2010 and everything seem to be working fine.
    Thanks a lot!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now