question

VenkataRamanaNori-1428 avatar image
1 Vote"
VenkataRamanaNori-1428 asked MilesGrayBuckton-3892 commented

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


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


dotnet-csharp
image.png (12.1 KiB)
image.png (72 B)
image.png (91.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

hi
did you get any solution of this issue?

0 Votes 0 ·
DanielZhang-MSFT avatar image
0 Votes"
DanielZhang-MSFT answered Alan-6046 published

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.


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Funcionou para mim, mas na verdade eu apaguei a pasta 1.9 pois minha versão funcional do office era a 2013. Muito obrigado....

0 Votes 0 ·

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

0 Votes 0 ·

it works for me as well , thanks Daniel Zhang

0 Votes 0 ·
DavidMills-3655 avatar image
2 Votes"
DavidMills-3655 answered MilesGrayBuckton-3892 commented

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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you @DavidMills-3655! :) The quick repair of Microsoft 365 Apps in the control panel worked for me! :D

0 Votes 0 ·
IOSIFDOHI-3529 avatar image
0 Votes"
IOSIFDOHI-3529 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.