Utilisation de l'objet CommandBarComboBox
Pour renvoyer un objet CommandBarComboBox, utilisez Controls(index), index étant le numéro d'index du contrôle. (La propriété Type du contrôle doit être msoControlEdit, msoControlDropdown, msoControlComboBox, msoControlButtonDropdown, msoControlSplitDropdown, msoControlOCXDropdown, msoControlGraphicCombo ou msoControlGraphicDropdown.)
L'exemple suivant montre comment ajouter deux éléments au deuxième contrôle de la barre de commandes intitulée « Custom », puis comment ajuster la taille du contrôle.
Set combo = CommandBars("Custom").Controls(2)
With combo
.AddItem "First Item", 1
.AddItem "Second Item", 2
.DropDownLines = 3
.DropDownWidth = 75
.ListIndex = 0
End With
Pour renvoyer un objet CommandBarComboBox, vous pouvez également utiliser la méthode FindControl. L'exemple suivant montre comment rechercher toutes les barres de commandes pour un objet CommandBarComboBox visible dont l'intitulé est « sheet assignments ».
Set myControl = CommandBars.FindControl _
(Type:=msoControlComboBox, Tag:="sheet assignments", Visible:=True)
Partager