Error Printing When Using Microssoft.office.interop

2

I was normally printing through an application that I developed in C # using interop in Office 2013 (Word). I then installed the version of office 2007 and from there, it did not work anymore. This is the exception I have:

     You can not convert the COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' in the interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the IID interface '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Error loading the library / DLL of type. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

I could not solve it, if someone can help me, I thank you.

c#
visual-studio
interop
office-interop

1 Answer

1

So what is happening is that you have an empty registry key of the higher version and because it always chooses the highest version it takes the empty one.

So you need to go in your registry and delete the empty version. To do that click on the windows icon then type regedit and press enter. You should then see the Registry Editor go in the folder HKEY_CLASSES_ROOT find the folder TypeLib in it and try to locate the key {00020905-0000-0000-C000-000000000046} (It's the Interop.Word key)

Now that you're in it you should have at least 2 folders in it. They should be named 8.X If you click on one you'll see to the right what it contains in one it will only have one line that starts with (Default). That folder is the empty one that you need to delete. Usually the highest folder is the one you need to delete so between 8.6 and 8.7 you should delete 8.7.

answered on Stack Overflow Mar 21, 2017 by I.B

User contributions licensed under CC BY-SA 3.0