Results 1 to 3 of 3

Thread: Passing parameters to OnAction function of a CommandBarComboBox

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    3

    Passing parameters to OnAction function of a CommandBarComboBox

    I am creating a dynamic CommandBarComboBoxes on a new Word document CommandBar. My problem is catching the currect ComboBox the user clicked on. Is there a way to pass arguments to the OnAction property of the CommandBarComboBox control. Remember, it is all done dynamically.
    Thanks in advance,
    Ilan.

  2. #2
    Fanatic Member WorkHorse's Avatar
    Join Date
    Jul 2002
    Location
    Where you live.
    Posts
    591
    The ActionControl property returns the control that called the sub by OnAction.

    VB Code:
    1. Sub AddMyCombo()
    2.    
    3.     Dim combo As CommandBarComboBox
    4.     Set combo = CommandBars("Custom 1").Controls.Add(msoControlComboBox)
    5.     With combo
    6.         .AddItem "First Item", 1
    7.         .AddItem "Second Item", 2
    8.         .DropDownLines = 3
    9.         .DropDownWidth = 75
    10.         .ListIndex = 0
    11.         .Tag = "MyNewCombo"
    12.         .OnAction = "MySub"
    13.     End With
    14.  
    15. End Sub
    16.  
    17. Sub MySub()
    18.  
    19.     With CommandBars.ActionControl
    20.         MsgBox .Tag & " = " & .List(.ListIndex)
    21.     End With
    22.  
    23. End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    3

    Thanks a lot.

    Very helpful and to the point.

Posting Permissions

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



Click Here to Expand Forum to Full Width