Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel- Running subroutines from a toolbar dropdown list

Status
Not open for further replies.

aflurry

Technical User
May 18, 2007
1
US
Hi,

This should be simple but i am having no luck. The code below is in ThisWorkbook because I want the code to run on the Active Sheet. The Toolbar "ibar" and the dropdown list "View" appear when I open the workbook. but I can't figure out how to run a different Subroutine depending on which item is chosen from the dropdown.

I know this is basic stuff, but i can't figure it out.

Code:
Sub Workbook_Open()

Dim ibar As CommandBar
Dim View As CommandBarControl

Set ibar = Application.CommandBars.Add(Name:="Implementation", Position:=msoBarTop)
ibar.Visible = True

Set View = ibar.Controls.Add(Type:=msoControlDropdown)
With View
    .Visible = True
    .Style = msoComboLabel
    .Tag = "viewlist"
    .Caption = "Choose View:"
    .AddItem "Worksheet - Expanded", 1
    .AddItem "Worksheet - Collapsed", 2
    .AddItem "Worksheet - Summary", 3
    .OnAction = "ThisworkBook.ChangeView"
End With
End Sub

Sub ChangeView()
?????
End Sub
 
In the VBA help take a look at the Change event of the CommandBarComboBox object.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top