Word COM Addin running under Outlook - Help!

A

Andrew M

Hello

I have a Word COM Addin that I want to disable when running under
Outlook (Word being the email editor). Is there a property that I can use to
determine if Word launched the addin, or Outlook.

Thanks for the help

Regards,

Andrew
 
K

Ken Slovak - [MVP - Outlook]

On_Connection. The Application object passed in that event would tell you
that.
 
A

Andrew M

Ken

Thank you for your response. Unfortuately, The Application object Passed
looks quite like the Word Application object. That is to say, I see no
discernable difference between the two. Could you point out a specific
property or parameter that would help me make this discernment?

Thanks,

Andrew
 
K

Ken Slovak - [MVP - Outlook]

Use Application.Name. It will contain the string "Word" or "Excel" or
"PowerPoint" or whatever.
 
T

tingletanglebob

Hi Ken,

I share the same problem - and it is saying "Microsoft Word" NOT "Microsoft
Outlook". So, the question is still pending (How to determine if Word was
starting in the context of Outlook or on its own - and then preventing the
Word-AddIn from being executed if Outlook was loaded)
 
K

Ken Slovak - [MVP - Outlook]

Note that I said "contain" the string "Word", you can test for that or test
for the full string of "Microsoft Word".

If you handle the Document_Activate event in Word you get a procedure that
looks something like this:
Private Sub oWord_WindowActivate(ByVal Doc As Word.Document, ByVal Wn As
Word.Window)

You can test in that event handler for Wn.EnvelopeVisible, which will tell
you if the document was opened as a WordMail document. From that you can
decide to disable the Word addin or if the code is in Word you can just
bypass the initializations for the addin.
 
A

Alex

tingletanglebob said:
Hi Ken,

I share the same problem - and it is saying "Microsoft Word" NOT "Microsoft
Outlook". So, the question is still pending (How to determine if Word was
starting in the context of Outlook or on its own - and then preventing the
Word-AddIn from being executed if Outlook was loaded)

The following works for me:

public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode,
object addInInst, ref System.Array custom)
{
// Do not run if application is embedded
if ((int) custom.GetValue(1) != 1)
return;

// ...
}


Best wishes,
Alex.
 
T

tingletanglebob

Thanks Ken,

your solution is working fine - and I am stopping to get grey hairs :)
 

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