tags:

views:

377

answers:

5

I've written a VSTO addin for Word 2003 which is working correctly. The only problem is that the adding 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?

Thanks,

Brian.

+1  A: 

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?

Ben Robbins
A: 

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

Richard Gadsden
A: 

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.

Jon
A: 

Hello, I am having the same problem! I am developing a shared addin using c sharp. is there any equivalent to document.kind in c sharp. Thanks in advance.

NChe
A: 

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.

drventure