How to Add Icon to a Excel Menu/Toolbar Button

Posted by nimo on Stack Overflow See other posts from Stack Overflow or by nimo
Published on 2010-05-15T19:24:10Z Indexed on 2010/05/15 19:34 UTC
Read the original article Hit count: 197

Filed under:
|

Hi,

I need to add a image to a custom toolbar/menu item which is create through VBA.

For a toolbar item, I tried following code

Set NewBtn = TBar.Controls.Add(Type:=msoControlButton)
With NewBtn

.Picture = LoadPicture("mypic.bmp")
.OnAction = "'MyFunction""" & para1 & """'"  //VBA Function
'.Caption = "MyFunction"
.TooltipText = "MyFunction"
.Style = msoButtonCaption

End With

In the above code LoadPicture() does not seem to be working. My toolbar is initializing at the workbook load up event. I noticed that the image is loading to the toolbar button, but in a fraction of second it disappears and only item text is displayed. My image is 16x16 pixel bmp one.

Any help appreciate to get around this problem

Thank you

© Stack Overflow or respective owner

Related posts about excel

Related posts about vba