Mega Code Archive

 
Categories / VisualBasic Script / Application
 

Attaching a drop-down list to a command bar

Sub Make()     Dim TBar As commandBar     Dim NewDD As CommandBarControl     Set TBar = CommandBars.Add     Set NewDD = CommandBars("myBar").Controls.Add(Type:=msoControlDropdown)     With NewDD         .Caption = "Date"         .OnAction = "yourAction"         .Style = msoButtonAutomatic         For i = 1 To 2             .AddItem "Click"         Next i         .ListIndex = 1     End With End Sub Sub yourAction()     With CommandBars("MonthList").Controls("DateDD")         ActiveCell.value = .List(.ListIndex)     End With End Sub