ShowPopupMenu Function

Syntax
ShowPopupMenu(StrArray$( )[, PopupStyle][, XPos, YPos])
Group
User Input
Description
Show a popup menu and return the number of the item selected. The item number is the index of the StrArray selected minus LBound(StrArray). The value -1 is returned in no menu item is selected.
Parameters Description
StrArray$( ) This one-dimensional array of strings establishes the list of choices. All the non-null elements of the array are used.
PopupMenuStyle This controls how the popup menu is aligned. Any combination of styles may used together. See the table below.
XPos When the menu is put up the alignment will be at this window position. If this is omitted then the current mouse position is used.
YPos When the menu is put up the alignment will be at this window position. If this is omitted then the current mouse position is used.
PopupStyle Value Effect
vbPopupLeftTopAlign 0 Align menu left edge at XPos and top at YPos. (default)
vbPopupUseLeftButton 1 User can select menu choices with the left mouse button only.
vbPopupUseRightButton 2 User can select menu choices with the left or right mouse button.
vbPopupRightAlign 4 Align menu with right edge at the XPos.
vbPopupCenterAlign 8 Align menu center at the XPos.
vbPopupVCenterAlign 16 Align menu center at the YPos.
vbPopupBottomAlign 32 Align menu bottom at the YPos.

Sub Main
    Dim Items(0 To 2) As String
    Items(0) = "Item &1"
    Items(1) = "Item &2"
    Items(2) = "Item &3"
    X = ShowPopupMenu(Items) ' show popup menu
    Debug.Print X ' item selected
End Sub