ShowContextMenu Method

Displays a customized context menu at the specified screen coordinates.

expression.ShowContextMenu(x, y, Menu)

*expression   * Required. An expression that returns one of the objects in the Applies To list.

x   Required Long. Represents the x-coordinate where the context menu is to appear.

y   Required Long. Represents the y-coordinate where the context menu is to appear.

Menu   Required Variant. The array that contains the menu items to display.


This example displays a context menu.

Sub ShowMenu()

    Dim cmContextMenu(4)
    Dim cmClearSubMenu(2)

    cmClearSubMenu(0) = Array("&All", "ClearAll")
    cmClearSubMenu(1) = Array("&Formats", "ClearFormats")
    cmClearSubMenu(2) = Array("&Values", "ClearValues")

    cmContextMenu(0) = Array("Cu&t", "owc2")
    cmContextMenu(1) = Array("&Copy", "owc3")
    cmContextMenu(2) = Array("&Paste", "owc4")
    cmContextMenu(3) = Empty
    cmContextMenu(4) = Array("Clea&r", cmClearSubMenu)

    Spreadsheet1.ShowContextMenu 10, 40, cmContextMenu

End Sub

Applies to | ChartSpace Object | PivotTable Object | Spreadsheet Object

See Also | BeforeContextMenu Event