1
votes

I've written a VSTO addin for Word 2003 which is working correctly. The only problem is that the addin displays a commandbar which is also appearing when I create a new email in Outlook. How can I prevent the commandbar addin from displaying in the context of Outlook and only in Word?

4
Is your copy of Outlook configured to use Word as the editor for email messages?Rowland Shaw

4 Answers

2
votes

Your problem is that Outlook is using Word as the editor for email messages.

You can turn that off from Tools Options Mail Format in Outlook, or you can will need to do detection, for instance the Document.Kind property, will have a value of wdDocumentEmail (=2) if it's an email message

1
votes

I haven't tried this, but can you use the Parent property of the Word instance to determine if its parent is Outlook and in that case not display the commandbar?

0
votes

The parent property just keeps looping back to Microsoft Word, and never to Outlook. I ended up importing User32.dll and getting the windows name, and then checking to see if that contained Microsoft Word.

The only problem I am still having is that if a user opens Outlook, creates a new message, and then opens Word, the WINWORD.exe process still has what im assuming to be the default template, and therefore the new copy word will not show my plugin.

0
votes

There's several properties in Word that should let you detect whether it's being run as a mail editor or not.

App.MailEnvelope App.Envelope App.Email

All return email related information. I believe at least one of them will return NOTHING if word is NOT being used as an email editor, but I no longer have access to that code, so I couldn't be sure without trying it out.

That said, I do know that even MS recommends against using Word as email editor. in Office 2007 and 2010, I don't believe that's even an option anymore.