Unable to cast COM object of the type Microsoft.Office.Interop.Word.ApplicationClass to type Microsoft.Office.Interop.Outlook._Application

Add-in Express™ Support Service
That's what is more important than anything else

Unable to cast COM object of the type Microsoft.Office.Interop.Word.ApplicationClass to type Microsoft.Office.Interop.Outlook._Application
Trying to cast Word instead of Outlook 
Mike VE




Posts: 168
Joined: 2007-09-09
A client who uses my add-in keeps getting this very strange exception.

Unable to cast COM object of the type Microsoft.Office.Interop.Word.ApplicationClass to type Microsoft.Office.Interop.Outlook._Application

They have used my add-n for quite a while. The error occurred after they installed the current version but I then found out they had also upgrade Office to 2013 and I think that may be part of the problem. I can find reference to similar exceptions on the web but the all relate to Registry entries for different versions of Word. This exception seems to be because the add-in is trying to call Outlook but getting Word instead.

I have not yet managed to get the full exception stack. The addin uses ADX 7.7.4087.2005. It is an Outlook add-in but does use an instance of Word to count words in the email body.

Any idea what is going on?
Posted 03 Oct, 2015 13:18:08 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Mike,

For example, this will occur if you get a Word.Application using the Word.Range.Application property and cast it to Outlook.Application.


Andrei Smolin
Add-in Express Team Leader
Posted 05 Oct, 2015 02:51:06 Top
Mike VE




Posts: 168
Joined: 2007-09-09
Thanks Andrei

I guess there must be some ambiguity in the references somewhere. I'll check all my imports and using statements to make sure they are explicit i.e. imports Outlook=Microsoft.Interop.Office.Outlook.
Posted 07 Oct, 2015 12:03:35 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Mike,

May I ask you to share your findings with forum readers?


Andrei Smolin
Add-in Express Team Leader
Posted 08 Oct, 2015 01:51:04 Top
Mike VE




Posts: 168
Joined: 2007-09-09
Hi Andrei

Sorry for the delay but I could not get further details from the user and I hoped my tidying up the references had done the trick. However the error is apparently still occurring and the user sent me another screenshot. My error handling code usually sends me an email with the full details but these are not being sent. Anyway, studying the screenshot gave me a couple more clues.

1. The title line of the message box should read "There was a problem in " and the ProductName of the add-in assembly - in the screenshot there is no such product name shown. The error handling code lies in a separate DLL and for some reason it is not reading the ProductName of the add-in, which is passed to the DLL code as a property.

2. The body of the error message gives the both the exception message and the exception site.

Message: : Unable to cast COM object of type ?Â?Ð?èMicrosoft.Office.Interop.Word.ApplicationClass?Â?Ð?é to interface type Microsoft.Office.Interop.Outlook._Application?Â?Ð?é.
The operation failed because the QueryInterface call on the COM component for the interface with IID?Â?Ð?é{00063001-0000-C000-000000000046}?Â?Ð?é failed due to the following error. No such interface supported (Exception from HRESULT:0x80004002 (E_NOINTERFACE)).

Site: Microsoft.Office.Interop._Application get_OutlookApp()

In my previous post I just gave the first part of the message and not the site.

3. The screenshot shows the MessageBox with the exception details in front of Word but the add-in is for Outlook, not Word, though it does make some optional use of an invisible instance of Word. The task bar in the screenshot shows that Outlook is running.

I think the exception site is probably the most most important of the clues but am not sure what to make of it. Any ideas?
Posted 29 Oct, 2015 11:52:27 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Mike,

Mike VE writes:
Site: Microsoft.Office.Interop._Application get_OutlookApp()


You call the OutlookApp property of the add-in module. This property casts ADXAddinModule.HostApplication to Outlook._Application. The casts fails which means your add-in lists Word in the ADXAddinModule.SupportedApps property.


Andrei Smolin
Add-in Express Team Leader
Posted 30 Oct, 2015 03:25:59 Top
Mike VE




Posts: 168
Joined: 2007-09-09
Hi Andrei

No my add-in has only Outlook in the supported apps property. Does this link to a registry entry? I have a feeling that at a very early stage of development a couple of years ago it may have listed Word, though it wasn't under source control then and I have no way of checking. Is there any chance that some relic of this could be lurking in the client's Registry?
Posted 30 Oct, 2015 03:44:35 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Mike VE writes:
Is there any chance that some relic of this could be lurking in the client's Registry?


It may. You can start Word and check if your add-in is listed under any heading at File | Options | Add-ins.


Andrei Smolin
Add-in Express Team Leader
Posted 30 Oct, 2015 03:48:11 Top
Mike VE




Posts: 168
Joined: 2007-09-09
Thanks. I'll pass it on. Could fact that the error handler did not pick up the ProductName of the add-in indicate messed up Registry entries?
Posted 30 Oct, 2015 04:39:12 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
I doubt it. I suppose there's something else that breaks.


Andrei Smolin
Add-in Express Team Leader
Posted 30 Oct, 2015 04:44:09 Top