Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    Oct 2001
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo Toolbars (97)

    Hi,
    I have added a combo toolbar and am got stuck on how to identify the option selected.

    The combo menu option is setup and populated as follows.

    With cbSuBMnu3.Controls
    Set cbSuBMnu31_Combo = .Add(Type:=msoControlComboBox)
    End With

    With cbSuBMnu31_Combo
    .AddItem Text:="Option 1"
    .AddItem Text:="Option 2"
    .AddItem Text:="Option 3"
    .OnAction = "RunThisMacro"
    .DropDownLines = 10
    .DropDownWidth = 200
    .ListHeaderCount = 0


    I initially tried creating an "on action" for each option but it always ran the first "on action" registered. It would appear on one "on action" can be used and the resulting macro identify which was selected? How do you know which option was selected?

    guidance much appreciated.

    otk

  2. #2
    Lounger
    Join Date
    Oct 2001
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Toolbars (97)

    For the benefit of anyone trying something similar, all items in the dropdown trigger the same "on action" which is resolved by a function. So , with some assistnace from msdn, the original code is amended as follows,

    With cbSuBMnu3.Controls
    Set cbSuBMnu31_Combo = .Add(Type:=msoControlComboBox)
    End With

    With cbSuBMnu31_Combo
    For zcount = 1 To UBound(AvailableRequests)
    .AddItem Text:=AvailableRequests(zcount), Index:=zcount
    Next zcount
    .OnAction = "SubMenu31Action"
    .Caption = "Form :"
    .Tag = "lstPrint"
    .DropDownLines = 10
    .DropDownWidth = 200
    .ListHeaderCount = 0
    End With

    Function SubMenu31Action()
    Dim ctl As CommandBarControl
    Set ctl = Application.CommandBars.ActionControl

    With ctl
    Debug.Print .Tag

    If .Tag = "lstPrint" Then

    Select Case Trim(ctl.Text)
    Case "Create Directory"
    MsgBox "The User Chose " & .Text
    Case "Rename existing Directory"
    MsgBox "The User Chose " & .Text
    Case "Change access rights"
    MsgBox "The User Chose " & .Text
    End Select

    End If

    End With

    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •