Setting Picture of Office CommandBar Button

S

StevenBr

I am using VB6 to create a simple Outlook add-in that temporarily adds a
commandbar with one button to the Outlook message form. I've used various
samples on both support.microsoft.com and in "Building Applications with
Outlook".

When I set the picture property as follows, I get an error in the picture
method:

Dim cbrTessOLBar As CommandBar
Dim cbTessOLLogSend As CommandBarButton
Dim picPicture As IPictureDisp

Set cbrTessOLBar = Inspector.CommandBars.Add("cbTessOL", msoBarTop, True)
Set cbTessOLLogSend = cbrTessOLBar.Controls.Add(msoControlButton)
cbTessOLLogSend.Style = msoButtonIconAndCaption
cbTessOLLogSend.Caption = "Log && Send"

Set picPicture =
stdole.StdFunctions.LoadPicture("t:\projects\emaillogging\imp256.bmp")

cbTessOLLogSend.Picture = picPicture
cbTessOLLogSend.Visible = True
cbrTessOLBar.Visible = True

I've read that the picture property doesn't support marshalling across
process, so it doesn't surprise me that I get this error when running the
add-in DLL in the VB IDE. However, when it's compiled and used within
Outlook, the error persists.

Is it even possible to set the command bar button's picture property in an
Outlook add-in?

Thanks.
 
S

sswater shi

In article 288771, the clipboard format name is "Toolbar Button Face". If
Office is not English version, the clipboard format name should be localized.
For example, if Office is French, German, Japanese, Chinese version etc, the
format name "Toolbar Button Face" will not work.

Anyone know how to get the localized clipboard format name ?
 
S

StevenBr

The error when the add-in is running within outlook is "method ~ of object ~
failed". When running in the IDE, it's "method picture failed" or something
similar.


--
Steven Bras
Tessitura Network, Inc.


Ken Slovak - said:
What is the error? What version of Outlook?
 
S

StevenBr

Thanks, that's an interesting article. But I don't need transparency and all
the examples I've found are far simpler, like the code I'm using. Because so
many resources say it should work, I'd like to find out why it doesn't.
 
P

Peter Huang [MSFT]

Hi Steve,

What is the size of your picture?
I think you may try a 32x32 picture first to see if that works.
Also to troubleshoot such issue, a better approach is trying to run the
code in the Outlook VBA macro.

Because the VB syntax is similar, I think we did not need to do much
change. Also if we debug in VBA, we will not encounter the process boundary
issue.

Please have a try and let me know the result.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Ken Slovak - [MVP - Outlook]

I doubt it's an interprocess boundary issue, I've never run into that with
VB 6 in the IDE or in running code in a COM addin. What it might be, as
Peter mentioned, is the BMP itself. The specs for an Office button icon call
for a 16x16x256 color bitmap. Is your conformant with the spec?
 
S

StevenBr

Yes; I saw that same spec and double-checked my .bmp file. It's 16 x 16, 256
colors. I've tried one with 16 colors with the same results. Thanks.
--
Steven Bras
Tessitura Network, Inc.


Ken Slovak - said:
I doubt it's an interprocess boundary issue, I've never run into that with
VB 6 in the IDE or in running code in a COM addin. What it might be, as
Peter mentioned, is the BMP itself. The specs for an Office button icon call
for a 16x16x256 color bitmap. Is your conformant with the spec?
 
K

Ken Slovak - [MVP - Outlook]

I'm about out if ideas then. About the only other thing I can think of is to
try fully qualifying your references:
Dim picPicture As stdOLE.IPictDisp
Dim cbTessOLLogSend As Office.CommandBarButton

and so on and see if that helps.

The other thing to try is to declare the picture object as StdPicture:

Dim picPicture As StdPicture
 

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