Can you place a combo box in a custom toolbar?

C

Chip Pearson

Try something like the following:

Sub Init()
Dim Cbx As Office.CommandBarComboBox
Set Cbx = Application.CommandBars("Standard").Controls.Add( _
Type:=msoControlComboBox)
With Cbx
.Caption = "Choose"
.Tag = "Combobox1"
.AddItem "Item 1"
.AddItem "Item 2"
.AddItem "Item 3"
.OnAction = ThisWorkbook.Name & "!CbxClick"
End With
End Sub

Sub CbxClick()
Dim Cbx As Office.CommandBarComboBox
Set Cbx = Application.CommandBars.ActionControl
MsgBox "You choose: " & Cbx.List(Cbx.ListIndex)
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Combo box 0
Combo or list box 0
Combo or list box 0
combo box 2
Combo boxes in excel 6
Publisher office 365 0
Having trouble with combo boxes. 11
Combo Box Question 22

Top