SelectMenu

<< Click to Display Table of Contents >>

 

SelectMenu

SelectMenu(Menu, [Left], [Top])

This method displays a contextual menu as specified by the Menu parameter. This parameter is a text with several options delimited by a vertical bar (|), and each one of these Strings is a menu option. In case there is a set of two consecutive delimiters (||), a separator is inserted. Use opening and closing braces to create a submenu. An asterisk in front of a String indicates a selected option. An exclamation point indicates that the option is disabled.

Dialog box's position can be configured using the optional Left and Top parameters, which indicate the distance from Screen's left margin and top in pixels, respectively. In case these parameters are not informed, this menu is positioned according to the region where the mouse pointer was clicked.

This method returns 0 (zero) if no option is selected, or an option number, 1 (one) for the first option, 2 (two) for the second, and so on. Example:

Sub Button1_Click()
  op = _
    Application.SelectMenu(_
      "Option1||Option2{*Option2|Option3}|Option4|!Opption5")
  If op = 1 Then
    MsgBox "Option 1 was selected"
  ElseIf op = 2 Then
    MsgBox "Option 2 was selected"
  ElseIf op = 3 Then
    MsgBox "Option 3 was selected"
  ElseIf op = 4 Then
    MsgBox "Option 4 was selected"
  ElseIf op = 0 Then
    MsgBox "No option was selected"
  End If
End Sub

Was this page useful?