Inspector.CommandBars and Word

M

Mike Hildner

Hello,

I posted this in the general .net group a couple days ago and didn't get a
response.

I'd like to add a toolbar (CommandBar) to the form that pops up when you
create a new mail message in Outlook. This works unless the email editor is
Word and Word is open at the time. In that case, the CommandBar gets added
to Word, not Outlook's form.

Searched around and it appears this is "by design" but of course the client
won't buy that. Any suggestions or work arounds?

Here's the code if it makes a difference

// Create a new CommandBar object.
_cb = Inspector.CommandBars.Add("Blah Blah",
Office.MsoBarPosition.msoBarTop, false, true);

//Create a CommandBarButton object.
_cbb =
(Office.CommandBarButton)_cb.Controls.Add(Office.MsoControlType.msoControlButton,
System.Type.Missing, System.Type.Missing, System.Type.Missing,
System.Type.Missing);
_cbb.Caption = "Elvis Lives!";
_cbb.Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonCaption;

//Make the new command bar visible.
_cb.Visible = true;


Thanks,
Mike
 
K

Ken Slovak - [MVP - Outlook]

There's not much you can do other than add to the Standard toolbar or one of
the main menus and no matter what the context will also be Word. To prevent
your buttons from showing up in normal Word documents you have to explicitly
delete your stuff (Word doesn't honor Temporary) and set the
CustomizationContext before you create your stuff.
 
J

John Svercek

Mike, problem is word.exe is only running once & gets confused when multiple
windows are open. The solution is to check in your NewInspector event to see
if wordmail is the editor. If so you need to instantiate a word doc from the
inspector item. Then in the word doc, use the windowactivate to add buttons
if Envelope.visible is true. If Envelope.visible is false then delete the
buttons.
 
K

Ken Slovak - [MVP - Outlook]

And make sure to explicitly find and delete any buttons you add using code
since Word doesn't honor the Temporary = True setting. You may have to
re-instantiate the button to be able to delete it in your remove code, I
always do, and you should set the CustomizationContext of where you create
the button and then set that .Saved = True after deleting so the user
doesn't get a prompt to save changes.
 

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