
Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
>I do get a NewInspector event for Outlook 2000 SP3 with WordMail. However,
>when I call CommandBars::Add, I get an exception and the toolbar doesn't
[quoted text clipped - 6 lines]
>
> Mark
Well, I'm using C++. Here's the relevant code (with unnecessary code
removed):
CComQIPtr<Office::_CommandBarButton> m_pSaveButton;
CComPtr<Office::_CommandBars> m_pCommandBars;
CComPtr<Office::CommandBar> m_pCommandBar;
{
m_pCommandBar = m_pCommandBars->Add(CComVariant(toolBarName),
CComVariant(msoBarTop), CComVariant(VARIANT_FALSE),
CComVariant(VARIANT_TRUE));
// Now get the tool bar's CommandBarControls
CComPtr<Office::CommandBarControls>
pBarControls(m_pCommandBar->GetControls());
// Add save button
m_pSaveButton = pBarControls->Add(CComVariant(msoControlButton),
vEmpty, vEmpty, vEmpty, CComVariant(VARIANT_TRUE));
// Set properties
m_pSaveButton->PutStyle(Office::msoButtonIconAndCaption);
m_pSaveButton->PutFaceId(1677);
m_pSaveButton->PutVisible(VARIANT_TRUE);
m_pSaveButton->PutEnabled(VARIANT_TRUE);
// Set caption
m_pSaveButton->put_Caption(caption);
}
I figured out that later on, when I get the OnClick notification, I can set
the caption just fine using the interface that is passed in to the function:
void __stdcall ToolBar::OnClickButton(IDispatch* Ctrl, VARIANT_BOOL *
CancelDefault)
{
CComQIPtr<Office::_CommandBarButton> pButton(Ctrl);
pButton->put_Caption(caption);
}
The funny thing is that the icon and the tooltip text work just fine. So
I'm confused...
Mark
>I wouldn't even attempt to support WordMail using code for Outlook 2000 at
>all. Just too funky even if you do get a NewInspector event. Without seeing
[quoted text clipped - 15 lines]
>>
>> Mark
Ken Slovak - [MVP - Outlook] - 25 Apr 2005 14:00 GMT
It looks like when you're getting the NewInspector event things with Word
just aren't completely set up yet. What you can do is set a Boolean module
level variable that you set True when the buttons have been created. Then
you can handle the Activate event for the Inspector and in that event
handler check the Boolean. If it's true the buttons have been set up. If not
then set them up. That way your init code doesn't run until the first
activation of the Inspector.

Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> Well, I'm using C++. Here's the relevant code (with unnecessary code
> removed):
[quoted text clipped - 42 lines]
>
> Mark
Mark Smith - 25 Apr 2005 17:54 GMT
I got it working. I hadn't been setting a tag name. Since in your previous
post you said something about looking up the control by id or tag name I
figured I'd set a tag name and go from there. Apparently, setting the tag
name was all that I needed for my caption to start working properly.
Strange...
Also, I am able to set the position of the toolbar just fine.
None of this has yet been tested with Office 2003 yet, but it seems to be
working great with Office 2002, so I am anticipating no problems with 2003
*fingers crossed*.
Now we would really like to support Office 2000. Do you think there is any
chance we could get this working?
Thanks for all of your help,
Mark
> It looks like when you're getting the NewInspector event things with Word
> just aren't completely set up yet. What you can do is set a Boolean module
[quoted text clipped - 50 lines]
>>
>> Mark
Mark Smith - 25 Apr 2005 18:11 GMT
Let me rephrase - I can set the position of the toolbar ALMOST correctly.
It works in most cases, but doesn't for some others.
Is there any reason I have to delete the toolbar? I did some testing to see
what the behavior would be. If I don't delete it, Outlook and Word still
close just fine. The toolbar persists between new WordMail instances within
the same Outlook session. But when I close Outlook and restart it, the
toolbar needs to be recreated again, unlike Outlook toolbars that are not
temporary.
Mark
>I got it working. I hadn't been setting a tag name. Since in your
>previous post you said something about looking up the control by id or tag
[quoted text clipped - 68 lines]
>>>
>>> Mark
Ken Slovak - [MVP - Outlook] - 26 Apr 2005 14:54 GMT
Leaving orphan toolbars and buttons around is never a very good idea. For
one thing if the user uninstalls your code the debris you created will still
be there.
Positioning a toolbar in Outlook usually mostly works, although your
position can be affected by other custom toolbars that are created by other
code and that are instantiated after your code runs. You can't guarantee
what addin will be instantiated before others, so you have no control over
that. Positioning in Word is much more of a problem and usually doesn't work
very well at all.
Outlook toolbars can also be created permanently, they live in Outcmd.dat.
If your buttons/bars have unique tags you can connect with them again on the
next startup, but again it's not at all a best practice.

Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> Let me rephrase - I can set the position of the toolbar ALMOST correctly.
> It works in most cases, but doesn't for some others.
[quoted text clipped - 7 lines]
>
> Mark