VBA 中有没有办法将列表框添加到工具栏(添加功能区)?我希望能够让用户在列表框中选择多个值/标准,而不是在下拉/组合框菜单中选择一个值。
下面的代码只添加了一个下拉菜单
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
请指教。如果您知道更好的方法来做到这一点,那也太好了!