How to assign icon to a button in Outlook Add-in

P

paresh

Hi,

I have wrtten Outlook COM Add-in. The attached code on startup creates the
button on outlook tool bar and assign the icon C:\local\cat.bmp. Could anyone
please tell me how could I make my Add-in independent of C:\local\cat.bmp? I
mean can I put picture somewhere in add-in itself so that while installing on
other machine it should have any problem if C:\local\cat.bmp is not there. OR
How could I use any system icon?

Set moCBMeow =
moApp.ActiveExplorer.CommandBars.Item("Standard").FindControl(, , "890",
False, True)
If TypeName(moCBMeow) = "Nothing" Then
Set moCBMeow =
moApp.ActiveExplorer.CommandBars.Item("Standard").Controls.Add(msoControlButton, , "890", , True)
End If
With moCBMeow
.BeginGroup = True
.Caption = "Copylink"
.DescriptionText = "Meow meow meow"
.Enabled = True
.OnAction = "!<CopyLinkTestingAddin.Connect>"
Clipboard.Clear
Clipboard.SetData LoadPicture("c:\local\cat.bmp")
.PasteFace
.Style = msoButtonIconAndCaption
.Tag = "890"
.ToolTipText = "Meow meow meow"
.Visible = True
End With


Thanks.
Paresh
 
K

Ken Slovak - [MVP - Outlook]

Any image supplied for a CommandBarButton object must be 16x16x256 colors.
If put on the clipboard it must be a BMP, if you use Picture/Mask you supply
an IPictureDisp object.

To re-use an Outlook button image you get the CommandBarButton with the
image you want and use CopyFace to put it on the clipboard for PasteFace to
grab.

For any other image you can put it in the resource file for your addin
project and grab it from there, using whatever method is available in the
language you are using for loading image resources.
 

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