Excel COM Error Cant Load Library Fix

Share on:

I've been getting the following error when trying to access a new Excel COM object:

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: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

The code I'm using was pretty simple PoSH that has worked for me before:

1$excel = New-Object -ComObject Excel.Application
2$excel.Visible = $true

After reading through dozens of posts where people were hacking up the registry to fix the issue after upgrades and downgrades (getting me nowhere), I started up Process Monitor and found that the file vbe6ext.olb was being searched for in just about every folder in my %PATH% but was never found.

I searched my system and found the file in C:\Program Files\Microsoft Office\root\vfs\ProgramFilesCommonX86\Microsoft Shared\VBA\VBA6. I wanted to copy the file into SYSWOW64 since it's a 32-bit file, but Process Monitor showed that Excel wasn't looking for the file there, so I copied it into c:\windows\system32 instead and it resolved my issue.

No comments