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

7

I am getting an 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 Query Interface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

When I am trying to open Excel application in VB.NET I tried to reinstall excel but didn't fix the problem.

excel
vb.net
asked on Stack Overflow Jan 10, 2017 by jafla nasif • edited Aug 27, 2019 by HackSlash

3 Answers

7

The error may say it can't load a DLL but if you are trying to load Excel that is where the problem is.

For some people, doing a simple Office repair from Add\Remove programs: Modify is enough to fix the problem.

If you have already tried an Office repair then you can fix it manually by editing the registry.

Open Regedit as admin and go to:

Computer\HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}\

This is the location that shows where Excel is installed. At this point if you see multiple versions, "1.9", "1.8", "1.7" then you need to remove the extra entries. For example Excel 2019 is "1.9" so if you would remove lower versions no longer installed.

Once you have only one version you also need to check the bitness. I had moved from 32-bit to 64-bit but both keys were still present

Computer\HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}\1.9\0\Win32
Computer\HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}\1.9\0\Win64

I removed the Win32 key and everything began working again. Inside these keys the default value shows the full path to EXCEL.EXE. Ensure that path is correct.

answered on Stack Overflow Aug 27, 2019 by HackSlash • edited Mar 30, 2021 by HackSlash
5

My issue resolved, after deleting 1.9 registry key under Start--> Run --> regedit --> HKEY_CLASSES_ROOT-->TypeLib-->{00020813-0000-0000-C000-000000000046} --> 1.9

answered on Stack Overflow Oct 3, 2018 by Bhupinder
2

I have the same problem, I searched for the solution for days . and today I found it, maybe can help you (I delete 1.9 and left 1.8)


If this is not a code related error than please remove below given key from registry.

Steps:

Start--> Run --> regedit --> HKEY_CLASSES_ROOT-->TypeLib-->{00020813-0000-0000-C000-000000000046} --> 1.8/1.7 (Delete this)

Solution: This issue can be resolved by deleting an invalid registry key left over from the higher version of Office. Follow the above steps.

Cause: This issue is caused by a left over registry key if you have downgraded your version of Microsoft Office from either Office 2010 to Office 2007, or Office 2013 to Office 2010 or 2007.

Let me know if this solution is not helped to you


LINK

unable to cast COM object of type 'microsoft.Office.Interop.Excel.ApplicationClass' to 'microsoft.Office.Interop.Excel.Application'"

LINK

answered on Stack Overflow Nov 8, 2017 by Aliendo

User contributions licensed under CC BY-SA 3.0