hostObj in WindowActivate event

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

hostObj in WindowActivate event

Posts: 11
Joined: 2018-08-28
I'm trying to use the WindowActivate event for Microsoft Project, but I can't figure out the type to cast hostObj to. Can you help me?

Thank you,

Posted 04 Dec, 2020 17:06:03 Top

Posts: 11
Joined: 2018-08-28
I've tried casting hostObj to MSProject.Project like this:

var currentProject = (MSProject.Project)hostObj;

I get this error:

Message=Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.MSProject.Project'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020B00-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Source=<Cannot evaluate the exception source>
<Cannot evaluate the exception stack trace>

I'm using the latest download of Add-in Express and the Microsoft Project Online Desktop Client (Office 365).
Posted 07 Dec, 2020 08:00:16 Top
Andrei Smolin

Add-in Express team

Posts: 18262
Joined: 2006-05-11
Hello Joe,

Try to cast to Project.Window.

Also, you can add a reference to Microsoft.VisualBasic and call Microsoft.VisualBasic.Information.TypeName({an object reference here}) to get a string representing the type name of the object.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 07 Dec, 2020 10:20:59 Top