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




Posts: 59
Joined: 2005-10-06
Hi,

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 (vb.net) that demonstrates this?

Thhanks in advance,

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


Add-in Express team


Posts: 7225
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