How can I add controls to a toolbar, using VBA code?
Kevin B - 20 Feb 2006 21:05 GMT
This will add a new control to the worksheet menu bar:
Sub NewControl()
Dim cmd As CommandBarButton
Set cmd = Application.CommandBars("Worksheet Menu Bar"). _
Controls.Add
With cmd
.BeginGroup = True
.Caption = "My New &Button"
.Style = msoButtonCaption
.BeginGroup = True
.OnAction = "Insert Macro Name Here"
End With
OnExit:
Set cmd = Nothing
End Sub

Signature
Kevin Backmann
> How can I add controls to a toolbar, using VBA code?
Kevin B - 20 Feb 2006 21:09 GMT
I was a bit too fast with the mouse click.
The .Caption statement is the name of your command with the ampersand
indicating which letter is the hot-key. And the OnAction statement is the
name of the macro you want to execute when the user clicks the button.

Signature
Kevin Backmann
> How can I add controls to a toolbar, using VBA code?