Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass'

Venkata Ramana Nori 36 Reputation points
2021-02-04T07:21:21.033+00:00

Hi

I've this C# application which opens excel file and updated another excel file. The application developed in Visual studio 2005 and Office 2016.

I've recently uninstalled Office 2016 and installed Office 365. Since then " Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' " an error is generated (Image attached)

I've searched web but didn't get any idea on how to solve this error???

63887-image.png

63839-image.png

63895-image.png

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,352 questions
{count} votes

6 answers

Sort by: Most helpful
  1. David Mills 51 Reputation points
    2022-03-23T06:02:32.847+00:00

    Thank you = try to repair your Office 365 in control panel. = WORKED

    10 people found this answer helpful.

  2. Daniel Zhang-MSFT 9,621 Reputation points
    2021-02-05T06:05:00.023+00:00

    Hi VenkataRamanaNori-1428,
    This problem is mostly caused by incorrect COM Interop settings in the Windows registry. This can be caused by installing a newer version of Microsoft Office, and then removing it and installing an older version instead. There are other ways this could happen.
    If this is not a code related error than please remove below given key from registry.
    Please follow steps below:
    Start-->Run --> regedit --> HKEY_CLASSES_ROOT-->TypeLib-->{00020813-0000-0000-C000-000000000046} --> 1.8/1.7 (Delete this)
    If not successful, you can try to repaire your Office 365 in control panel. Then, try again. If the problem still exists, you can completely uninstall, reboot, and then reinstall Office.
    Here are also some similar threads you can refer to.
    unable to cast COM object of type 'microsoft.Office.Interop.Excel.ApplicationClass' to 'microsoft.Office.Interop.Excel.Application'"
    How to solve “Unable to cast COM object of type Microsoft.Office.Interop.Excel.ApplicationClass’ to interface type ‘Microsoft.Office.Interop.Excel._Application’”
    How to solve “Unable to cast COM object of type Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'”
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

  3. IOSIF DOHI 11 Reputation points
    2022-05-24T08:49:00.887+00:00

    This problem appears after uninstall a MSOffice version, a restart is NOT made immediately and automatically a new install of a new version of MSOffice is done. The Windows registry is not cleaned up. Happily, after a restart is made, the Modify/Repair of MSOffice in Control panel/Programs and features solves this problem. Tried also for MSOffice 2007, 2021.

    2 people found this answer helpful.
    0 comments No comments

  4. Ralk 11 Reputation points
    2022-11-30T09:28:28.59+00:00

    Working like a charm. This-> try to repair your Office 365 in control panel. = Worked!

    2 people found this answer helpful.
    0 comments No comments

  5. Gary Gwynn 10 Reputation points
    2023-03-27T13:55:13.51+00:00

    and if you have a Mac and getting this what can you do.

    2 people found this answer helpful.