BEst way to determine which host application fired an event?

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

BEst way to determine which host application fired an event?
Brendon Colloty



I have a shared add in that needs to run in Excel, Word, Powerpoint, Project and Visio.

In the click event of a button on my shared toolbar I need to determine which application fired the event, return a reference to the correct object (Word.application, excel.application etc) and based on the typpe I will run code that is approproate to the office application (I'm effectively doing a Save As but it varies based on the app).

Whats the best way to do this in Add-In Express?

Do you have a sample ( that demonstrates this?

Thhanks in advance,

Posted 14 Aug, 2006 05:43:57 Top
Sergey Grischenko

Add-in Express team

Posts: 7233
Joined: 2004-07-05
Hi Brendon.

You can use the code below:

Private Sub AdxCommandBarButton1_Click(ByVal sender As System.Object) Handles AdxCommandBarButton1.Click
Select Case Me.HostType
Case AddinExpress.MSO.ADXOfficeHostApp.ohaExcel

Case AddinExpress.MSO.ADXOfficeHostApp.ohaPowerPoint

Case AddinExpress.MSO.ADXOfficeHostApp.ohaProject

Case AddinExpress.MSO.ADXOfficeHostApp.ohaVisio

Case AddinExpress.MSO.ADXOfficeHostApp.ohaWord

End Select
End Sub
Posted 14 Aug, 2006 15:46:26 Top