This example checks the number of items in the combo box on the command bar named "Custom." If there aren’t three items in the list that the procedure produces, the example displays a message advising the user that the combo box may be damaged and asks the user to reinstall the application.
Set myBar = CommandBars _
.Add(Name:="Custom", Position:=msoBarTop, _
Temporary:=True)
With myBar
.Controls.Add Type:=msoControlComboBox, ID:=1
.Visible = True
End With
With CommandBars("Custom").Controls(1)
.AddItem "Get Stock Quote", 1
.AddItem "View Chart", 2
.AddItem "View Fundamentals", 3
.Caption = "Stock Data"
.DescriptionText = "View Data For Stock"
End With
If CommandBars("Custom").Controls(1).ListCount _
<> 4 Then
MsgBox ("ComboBox appears to be damaged." & _
" Please reinstall.")
End If