R
Robb
When I create a combobox on an Excel toolbar I want the user to only be able to select items I have
added to the list, not to be able to start typing things. What happens is the user can click on the
combobox and start typing stuff. In VB you set the style property to 2 - Dropdown List to restrict
this. In VBA the style property takes either 0-msoComboNatural or 1-msoComboLabel. Neither of which
affect the style in the same manner as VB's style property. Actually I can't see any difference
between either of those combobox constants.
Here is the code I use to create the combobox.
Dim X As CommandBarComboBox
Set X = .Controls.Add(msoControlComboBox, , , , True) 'ADD BUTTON IN TEMPORARY MODE
X.AddItem "Tarus Reports", 1
X.AddItem "Comparison", 2
X.AddItem "Standard", 3
X.AddItem "SPC", 4
X.AddItem "About", 5
X.ListIndex = 1
X.Style = msoComboLabel
X.DropDownLines = 5
X.DropDownWidth = 75
X.Tag = "Tarus Reports"
X.OnAction = "LaunchWhichReport"
Discussion Sidebar: Why do you suppose the default behaviour for a combobox is to allow the user to
type stuff into a combobox. I have never written a program using that method to allow a user to
dynamically add items. And of course I could be wrong but I can't recall ever seeing that input
method applied in any application I have ever used.
added to the list, not to be able to start typing things. What happens is the user can click on the
combobox and start typing stuff. In VB you set the style property to 2 - Dropdown List to restrict
this. In VBA the style property takes either 0-msoComboNatural or 1-msoComboLabel. Neither of which
affect the style in the same manner as VB's style property. Actually I can't see any difference
between either of those combobox constants.
Here is the code I use to create the combobox.
Dim X As CommandBarComboBox
Set X = .Controls.Add(msoControlComboBox, , , , True) 'ADD BUTTON IN TEMPORARY MODE
X.AddItem "Tarus Reports", 1
X.AddItem "Comparison", 2
X.AddItem "Standard", 3
X.AddItem "SPC", 4
X.AddItem "About", 5
X.ListIndex = 1
X.Style = msoComboLabel
X.DropDownLines = 5
X.DropDownWidth = 75
X.Tag = "Tarus Reports"
X.OnAction = "LaunchWhichReport"
Discussion Sidebar: Why do you suppose the default behaviour for a combobox is to allow the user to
type stuff into a combobox. I have never written a program using that method to allow a user to
dynamically add items. And of course I could be wrong but I can't recall ever seeing that input
method applied in any application I have ever used.