tags:

views:

31

answers:

2

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

+1  A: 

Use MsoButtonStyle.msoButtonIcon or one of the MsoButtonStyle members that contain the word Icon.

AMissico
A: 

In VBA I store the icons on a worksheet (oTemplate) and transfer them to the buttons using:
with NewBtn
oTemplate.Shapes("picCalcOpt").CopyPicture
.PasteFace

Charles Williams