Custom CommandBars

F

Fan924

Here is a simple one button menu bar. How do I add a custom image to
replace the face ID? I can't find a good web reference for this.


Sub CreateMenr()
On Error Resume Next
Application.CommandBars("example").Delete
Set myCB = CommandBars.Add(Name:="example",
Position:=msoBarFloating)

' Add a button to this bar
Set myCBtn2 = myCB.Controls.Add(Type:=msoControlButton)
With myCBtn2
.FaceId = 17 ' <- Face Id 17 is a barchart icon
.Caption = "Descriptive stat"
End With
myCB.Visible = True
End Sub
 
S

Starwing

try it:

Sub CreateMenu()
On Error Resume Next
Application.CommandBars("example").Delete
Set myCB = CommandBars.Add(Name:="example",
Position:=msoBarFloating)

' Add a button to this bar
Set myCBtn2 = myCB.Controls.Add(Type:=msoControlButton)
Set menu3 = myCBtn2.CommandBar.Controls _
..Add(Type:=msoControlButton, ID:=1)
menu3.Caption = "Descriptive stat"
menu3.OnAction = "Your action"
menu3.FaceId = 17
myCB.Visible = True
End Sub
 
B

Bob Phillips

cbTable.Shapes(shapename).Copy­Picture
cbCtl.PasteFace

where cbTable is the codename of the sheet containing the picture, shapename
is the name of the shape, such as 'Picture 30', and cbCtl is an object
variable for the control being added.



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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