Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to cast COM object of Office Interop Word

My application has a feature to export to Microsoft Word, but it hasn't worked since I've upgraded from Microsoft Office 2010 to Microsoft Office 2013.

Here is the code:

Microsoft.Office.Interop.Word.Application appVersion = new Microsoft.Office.Interop.Word.Application();
appVersion.Visible = false;

and this is the error message:

Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Someone told me to edit the registry, but the IID "{00020970-0000-0000-C000-000000000046}" does not exist in my registry.

like image 841
aiyagaze Avatar asked Mar 12 '14 02:03

aiyagaze


3 Answers

Running a repair installation of Office usually resolves that issue.

like image 65
cremor Avatar answered Oct 20 '22 00:10

cremor


I had the exact same problem and reinstalling Office 2013 solved my issue.

like image 30
Alex Jolig Avatar answered Oct 20 '22 00:10

Alex Jolig


I switched from using Word Interop to using Late Binding. Quick fix that didn't affect refactoring a lot of code...

Before:

OfficeWord.Application msword = new OfficeWord.Application();

After:

Type wordType = Type.GetTypeFromProgID("Word.Application");
dynamic msword = Activator.CreateInstance(wordType);

Solved my issues on a bunch of corporate computers that started seeing this problem after an Office upgrade by Client Support.

like image 24
Popeye Avatar answered Oct 19 '22 23:10

Popeye