change of each item
What do you change, ComboBox or Shape ? If ComboBox I have an example.
Public Sub AddComboBox()
Dim cbars As Office.CommandBars
Dim cbar As Office.CommandBar
Dim cbButton As Office.CommandBarButton
Dim cbCombo As Office.CommandBarComboBox
On Error GoTo ERRHAND
Set cbars = Application.CommandBars
Set cbar = cbars.Add(Name:="MyDrawingCommandBar", Position:=msoBarTop,
Temporary:=True)
cbar.Protection = msoBarNoCustomize
'* = visible in given context.
cbar.Context = Str(visUIObjSetDrawing) & "*"
Set cbCombo = cbar.Controls.Add(Type:=msoControlComboBox)
With cbCombo
.Caption = "Combo Box"
.AddItem "Good Morning"
.AddItem "Good Day"
.AddItem "Good Night"
.TooltipText = "Click this button to run a VBA Macro"
.Tag = "cbbVBAMacro"
.OnAction = "Macro_Combo"
End With
Set cbCombo = Nothing
ERRHAND:
End Sub
Public Sub DeleteCommandBar()
Dim cbar As Office.CommandBar
Dim cbCombo As CommandBarComboBox
On Error Resume Next
Set cbar = Application.CommandBars("MyDrawingCommandBar")
cbar.Delete
End Sub
Public Sub Macro_Combo()
Dim cbCombo As CommandBarComboBox
Set cbCombo =
Application.CommandBars("MyDrawingCommandBar").Controls("Combo Box")
Select Case cbCombo.ListIndex
Case 1: GoodMorning: cbCombo.TooltipText = "Say Good Morning"
Case 2: GoodDay: cbCombo.TooltipText = "Say Good Day"
Case 3: GoodNight: cbCombo.TooltipText = "Say Good Night"
End Select
End Sub
Public Sub GoodMorning()
MsgBox "Good Morning, EveryBody!"
End Sub
Public Sub GoodDay()
MsgBox "Good Day, John!"
End Sub
Public Sub GoodNight()
MsgBox "Good Night, Baby!"
End Sub