• Combo Toolbars (97)

    Author
    Topic
    #367688

    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

    Viewing 0 reply threads
    Author
    Replies
    • #574230

      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

    Viewing 0 reply threads
    Reply To: Combo Toolbars (97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: