Is there a way in VBA to add a ListBox to a toolbar (Add In ribbon)? I want to be able to let the user select multiple values/criteria in a listbox instead of just one value in a dropdown/combobox menu.
The below code adds a dropdown menu only
Sub addSelectControls()
Dim newBar As Office.CommandBar
Set newBar = CommandBars.Add(Name:="testing CommandBar", temporary:=True)
Dim newCombo As Office.CommandBarComboBox
Set newCombo = newBar.Controls.Add(Type:=msoControlDropdown, temporary:=True)
With newCombo
.AddItem "Blocks"
.AddItem "Hardware"
.AddItem "Aircraft Hardware"
.AddItem "Vehical Hardware"
.AddItem "Machinery"
.AddItem "Wood Products"
.AddItem "Miscellaneous Products"
.AddItem "Miscellaneous Metal"
.AddItem "Precast Metal"
.AddItem "Forged Metal"
.AddItem "Structural Steel"
.AddItem "Fabricated Steel"
.AddItem "Prebent Steel"
.AddItem "Stock Steel"
.ListIndex = 13
.Width = 200
.Caption = "Category"
.Style = msoComboLabel
.BeginGroup = True
.OnAction = "Category_Select"
End With
'ctlComboBoxHandler.SyncBox newCombo
newBar.Visible = True
End Sub
Please advice. In case you know a better way to do this, that would be great too!