How to add an Icon to a commandBarButton

D

David

Hi,

I try To add an Icon(custom icon) to a commandBarButton.
I wrote the foloeing code in vba:

Dim myOlApp As New Outlook.Application
Dim objInsp As Outlook.Inspector
Dim objCBB As Office.CommandBarButton
Dim objCB As Office.CommandBar

Set myOlApp = CreateObject("Outlook.Application")
Set objInsp = myOlApp.ActiveInspector
Set objCB = objInsp.CommandBars("standard")
Set objCBB = objCB.Controls.Add(Type:=msoControlButton)
With objCBB
.Style = msoButtonIconAndCaption
.Caption = "MyAction"
.Visible = True
.Picture = stdole.LoadPicture("C:\Documents and Settings\MrkvLogo.ico")
.Mask = stdole.LoadPicture("C:\Documents and Settings\MrkvMask.ico")


End With

I get this error in ".Picture=..." and ".Mask=..." rows
Error message:
Run time error '5' :
Invalid procedure call or argument.

I use outlook 2003. However I need this code to work also with outlook 2000.


Thanks,
David
 
D

Dmitry Streblechenko

1. Use "set" when setting the Picture and Mask properties.
2. Picture and Mask properties were added in Outlook 2002, in Outlook 2000
you can only use CommandBarButton.PasteFace method to paste a bitmap
previously copied to the clipboard.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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