Problem with Inspector CommandBars and MS Word

Y

Yuri Loban

Hello all,

I have a next problem:

My Add-in adds a custom CommandBar with button into MailItem Inspector's
CommandBars object via NewInspector event. The MS Word editor is switched on.
It works properly.

But... If MS Word application was run before the MailItem Inspector was
opened (for example New Mail Message action), the Inspector's CommandBars
refers on MS Word application commandBar object !!!, therefor my custom
commandBar appears in MS Word application and action received from my custom
button from MS Word, not from Outlook MailItem Inspector.
What is wrong? How can I obtain Outlook Inspector CommandBar?

Regards,
Yuri
 
K

Ken Slovak - [MVP - Outlook]

Inspector.CommandBars works in all cases. With WordMail you can hide your
buttons when the mail envelope is not exposed using an events aware
Word.Application object in your Outlook code and handling the WindowActivate
event. If Window.EnvelopeVisible = True then the mailer is displayed. If
False then it's a Word document object.

With WordMail you are limited in which toolbars you can use and display, you
can work with Standard or create your own toolbar.
 
Y

Yuri Loban

Thanks for your advise. But, one problem is still here: I've used commandBar,
as you recomended, and it appears in both Outlook and Word application (?).
And unfortunately, my notification event for button in commandBar is attached
in Word application, not in Outlook. What could you guess?
 
K

Ken Slovak - [MVP - Outlook]

If your code runs and adds the button to the
Inspectors.CommandBars.Item("Standard") toolbar you should receive the Click
event in your Outlook code. I just add a button as usual whether it's
WordMail or not.

There are other things to account for with WordMail, such as the buttons
being in the Normal.dot template or wherever your CustomizationContext is
and when to hide and show the buttons, but the click event should fire
within your Outlook addin code.

If WordMail is running (Inspector.IsWordmail = True) then
Inspector.WordEditor is the Word Document object. WordEditor.Application is
Word.Application and WordEditor.ActiveWindow is your Word window. I already
mentioned how to figure out when to show or hide your buttons
(Window.EnvelopeVisible = True means WordMail is showing). Setting
CustomizationContext.Saved = True after adding or deleting your buttons will
prevent dialogs asking the user to save Normal.dot changes. You must
explicitly delete any WordMail buttons you add as Word does not honor the
Temporary = True argument. So you delete all your buttons when the Inspector
is closing.

Other than those things buttons in WordMail or the Outlook email editor are
the same.
 
Y

Yuri Loban

Thanks a lot!!!

Ken Slovak - said:
If your code runs and adds the button to the
Inspectors.CommandBars.Item("Standard") toolbar you should receive the Click
event in your Outlook code. I just add a button as usual whether it's
WordMail or not.

There are other things to account for with WordMail, such as the buttons
being in the Normal.dot template or wherever your CustomizationContext is
and when to hide and show the buttons, but the click event should fire
within your Outlook addin code.

If WordMail is running (Inspector.IsWordmail = True) then
Inspector.WordEditor is the Word Document object. WordEditor.Application is
Word.Application and WordEditor.ActiveWindow is your Word window. I already
mentioned how to figure out when to show or hide your buttons
(Window.EnvelopeVisible = True means WordMail is showing). Setting
CustomizationContext.Saved = True after adding or deleting your buttons will
prevent dialogs asking the user to save Normal.dot changes. You must
explicitly delete any WordMail buttons you add as Word does not honor the
Temporary = True argument. So you delete all your buttons when the Inspector
is closing.

Other than those things buttons in WordMail or the Outlook email editor are
the same.
 

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