Option Explicit
Sub CreateMyTool()
Dim cbMyTool As CommandBar
Dim cbbMyButton As CommandBarButton
Set cbMyTool = CommandBars.Add
Set cbbMyButton = cbMyTool.Controls.Add(msoControlButton)
With cbbMyButton
.OnAction = "DummyMacro1"
.FaceId = 645
.TooltipText = "Do magic with numbers"
End With
Set cbbMyButton = cbMyTool.Controls.Add(msoControlButton)
With cbbMyButton
.OnAction = "DummyMacro2"
.FaceId = 940
.TooltipText = "Show a message box"
End With
Set cbbMyButton = cbMyTool.Controls.Add(msoControlButton)
With cbbMyButton
.OnAction = "DummyMacro3"
.FaceId = 385
.TooltipText = "Functions"
End With
Set cbbMyButton = cbMyTool.Controls.Add(msoControlButton)
With cbbMyButton
.OnAction = "DummyMacro1"
.FaceId = 1662
.TooltipText = "Constraints"
End With
Set cbbMyButton = cbMyTool.Controls.Add(msoControlButton)
With cbbMyButton
.OnAction = "DummyMacro2"
.FaceId = 225
.TooltipText = "Lock cells"
End With
Set cbbMyButton = cbMyTool.Controls.Add(msoControlButton)
With cbbMyButton
.OnAction = "DummyMacro3"
.FaceId = 154
.TooltipText = "Delete all"
End With
Set cbbMyButton = cbMyTool.Controls.Add(msoControlButton)
With cbbMyButton
.OnAction = "DummyMacro1"
.FaceId = 155
.TooltipText = "Return"
End With
With cbMyTool
.Name = "Shortcuts"
.Left = Application.ActiveWindow.Width
.Top = Application.ActiveWindow.Height
.Visible = True
.Width = 300
End With
BeforeExit:
Set cbMyTool = Nothing
Set cbbMyButton = Nothing
Exit Sub
ErrorHandle:
MsgBox Err.Description & " CreateMyTool", vbOKOnly + vbCritical, "Error"
Resume BeforeExit
End Sub
Sub DeleteMyTool()
On Error Resume Next
CommandBars("Shortcuts").Delete
On Error GoTo 0
End Sub
Sub RemoveToolBar()
Dim cbBar As CommandBar
On Error GoTo ErrorHandle
For Each cbBar In Application.CommandBars
If Not cbBar.BuiltIn Then cbBar.Delete
Next
Exit Sub
ErrorHandle:
MsgBox Err.Description & " RemoveMenu", vbOKOnly, "Error"
End Sub