how to add a togglebutton to commandbar

  • Thread starter Thread starter Ko Vijn
  • Start date Start date
K

Ko Vijn

I have a primitive knowledge how to build a new commandbar and how to add
controls.
Usually I create simple controlbutons with statements as below. They run the
specified macro which works fine.

I would however also be able to add controlbuttons which behave like
togglebuttons like the send Email or Lock Cell button. Both are 'type 1'
buttons, so which property controls their toggling behaviour?

And, by the way, what is the difference between Style=0 and Style=0. Both
seem to set the control to Icon without text?

Thanks for any hints,
Ko

Example code:
'Create new Commandbar with name varCBR
Application.CommandBars.Add _
Name:=varCBR, Position:=msoBarTop, _
MenuBar:=False, temporary:=True
Application.CommandBars(varCBR).Visible = True

'Add controls
for i= 1 to varNumberControls
With Application.CommandBars(varCBR)
.Controls.Add Type:=1, ID:=2950, temporary:=True
next

'Install their properties from their respective arrays
for i= 1 to varNumberControls
With Application.CommandBars(varCBR).controls(i)
.OnAction = arrBtn_Macr(i) 'macro
.Caption = arrBtn_Capt(i) 'caption
.BeginGroup = arrBtn_BgGp(i) 'true/false
.Style = arrBtn_Styl(i) '0,1, 2 or 3
.TooltipText = arrBtn_TipT(i) '
.FaceID = arrBtn_Face(i) 'icon number
End With
Next
etcetera
 

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

Back
Top