Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Adding a button when using word to display rtf messages fails

Geek News

Adding a button when using word to display rtf messages fails
"james" <aceggroll[ at ]yahoo.com.au> 8/9/2006 1:32:07 PM
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

Re: Adding a button when using word to display rtf messages fails
"james" <aceggroll[ at ]yahoo.com.au> 8/11/2006 10:14:47 AM
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.)

james wrote:
[Quoted Text]
> 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

Re: Adding a button when using word to display rtf messages fails
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 8/11/2006 1:20:29 PM
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.

--
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


"james" <aceggroll[ at ]yahoo.com.au> wrote in message
news:1155291287.356362.134310[ at ]b28g2000cwb.googlegroups.com...
[Quoted Text]
> 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.)

Re: Adding a button when using word to display rtf messages fails
"james" <aceggroll[ at ]yahoo.com.au> 8/11/2006 2:32:20 PM
Hi Ken,

[Quoted Text]
> 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


Ken Slovak - [MVP - Outlook] wrote:
> 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.
>
> --
> 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
>
>
> "james" <aceggroll[ at ]yahoo.com.au> wrote in message
> news:1155291287.356362.134310[ at ]b28g2000cwb.googlegroups.com...
> > 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.)

Re: Adding a button when using word to display rtf messages fails
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 8/13/2006 5:42:04 PM
It's a limitation.

--
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


"james" <aceggroll[ at ]yahoo.com.au> wrote in message
news:1155306740.846487.23120[ at ]m73g2000cwd.googlegroups.com...
[Quoted Text]
> 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

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net