Shared Addin Host Check

N

NickP

Hi there,

I have a shared addin and would like to be able to check to see what the
host application is before acquiring my interfaces. How would I do this?

TIA.

Nick.
 
J

Jialiang Ge [MSFT]

Hello Nick,

From your post, my understanding on this issue is: you want to know what
the host application is in your program. If I'm off base, please feel free
to let me know.

All Office COM add-ins need to realize the interface: IDTExtensibility2, in
which the method OnConnection needs to be implemented. The method has a
parameter 'application' which points to your host application object,
therefore, we can know what the host application is by getting the type of
that pointer. For instance:

In C++, we can try to query Word._Application interface with
IDispatch.QueryInterface method, if it succeeds, it is a Word, otherwise,
try to query Excel._Application to determine whether it is an Excel
application.

In C#, the statement 'if (application is Word.Application)' will help to
determine whether is a Word application. 'application.GetType().FullName'
will also return 'Microsoft.Office.Interop.Word.ApplicationClass' to
indicate that the current host application is a Word.

In VB, please use the statement: 'If TypeOf application Is Word.Application
Then' to determine the host application.

Please let me know if you have any other concerns, or need anything else.

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
N

NickP

Hi Jialiang,

Many thanks for your help, that is pretty much what I ended up doing in
the end, although I was a little surprised that there is no identifier that
can be checked. Anyways, many thanks for your help, it works fantastic.

Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top