Adding a button when using word to display rtf messages fails

J

james

Hi All,

I'm attempting to add a button (or any other control!) to the inspector
when displaying messages.

The sample below can be executed, and it will add a toolbar and button
in 3 out of 4 cases.

Works for message composition, both with word-as-editor enabled and
disabled.
Works for message display, not using word for RTF.
Fails when using word to display RTF messages. (Outlook | Tools |
Options | MailFormat | Use Microsoft Office 2003 to read Rich Text
e-mail messages)

A discussion in another forum alluded to Word being used in a mode
whereby its command bars are read only. Is there any basis to this?
I also noticed that Outlook Spy (2.10.0.352) doesn't load its command
bar when word is used to display an RTF message.

I have also tried navigating to the wordDoc CommandBars, and tried (a)
adding a new CommandBar, and (b) adding a new button to an existing
CommandBar, but eventually get the same result in both cases on
attempting to add the new control.

Using Outlook 2003 SP1.

Does anyone have any ideas? Or is it time to give up, and look for some
other way to display message status info to the user?

' Sample code to work out why can't add button to Outlook Word RTF
viewer
' Doesn't work when Outlook set up to use Word to view RTF messages
' Throws error: "Method 'Add' of _CommandBars failed" ErrorID
0x80004005
' Works in other cases
' a) compose using word editor
' b) compose using rtf(?) editor
' c) display using rtf(?) viewer

Option Explicit

Dim WithEvents objInspectors As Outlook.Inspectors
Dim WithEvents objInspector As Outlook.Inspector
Dim objCommandBar As office.CommandBar
Dim objCommandBarCtrl As office.CommandBarButton

Private Sub Application_Quit()
Set objInspectors = Nothing
End Sub

Private Sub Application_Startup()
Set objInspectors = Application.Inspectors
End Sub

Private Sub objInspector_Close()
Set objCommandBarCtrl = Nothing
Set objCommandBar = Nothing
Set objInspector = Nothing
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
Set objInspector = Inspector
' fails on the following line
Set objCommandBar = objInspector.CommandBars.Add("Hello",
office.msoBarTop, True, True)
objCommandBar.Enabled = True
objCommandBar.Visible = True

Set objCommandBarCtrl =
objCommandBar.Controls.Add(office.msoControlButton)
objCommandBarCtrl.Style = msoButtonCaption
objCommandBarCtrl.Visible = True
objCommandBarCtrl.Enabled = True
objCommandBarCtrl.Caption = "World!"
End Sub
 
J

james

OK, no responses.

Try some other questions.

When word is used to display RTF messages, is the toolbar customizable?

Try this:
1. Send an RTF message using Outlook 2003.
2. Have a look in sent items, and display the message. Check that the
title bar shows that the messaeg is Rich Text.
3. Try manually customizing the toolbar. View | Toolbar. Note that
"Customize..." is disabled.

Does this mean also that the toolbar can't be progarmmatically
customized?

(Weird thing is that you can modify the message body - which normally
is readonly!)

Is this the same for anyone else, or is it just me setup?

(Please reply to maillist.)
 
K

Ken Slovak - [MVP - Outlook]

Customize is grayed out for any WordMail item (in the UI). Check it out with
a new HTML email.

When you're in WordMail you can access Inspector.CommandBars but what you
get is the Word CommandBars collection. You can add items to "Menu Bar" and
create your own toolbar (CommandBar). Adding to Standard or whatever isn't
going to work and forget about adding buttons to the mail envelope toolbars.
 
J

james

Hi Ken,
You can add items to "Menu Bar" and
create your own toolbar (CommandBar).

I tried this and failed adding a CommandBar when _reading_ an RTF
message with word (see sample code from original post). It does works
if I'm composing a message.

My Outlook Spy doesn't load its command bar in this mode either.

Just trying to work out if something in my setup is causing this
probelm, or if its a general Outlook/WordMail limitation.

thanks
 

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