HypExecuteMenu

Data provider types: All

Description

HypExecuteMenu() executes the specified menu or ribbon item.

You can use HypExecuteMenu only with these controls: button, split button, menu, dynamic menu, and toggle button (toggle buttons for extensions are not supported).

Syntax

HypExecuteMenu (vtSheetName, vtMenuName) As Long

ByVal vtSheetName As Variant

ByVal vtMenuName As Variant

Parameters

vtSheetName: Input parameter; the name of worksheet on which to run the function. If vtSheetName is Null or Empty, the active worksheet is used.

vtMenuName: Input parameter; the name of the menu item to execute.

Return Value

Returns 0 if successful; otherwise, returns the appropriate error code. Common error codes for this function are -15 (invalid parameter) and -73 (ambiguity: “Could not resolve menu name”).

Example

Public Declare Function HypExecuteMenu Lib "HsAddin" (ByVal vtSheetName As Variant,ByVal vtMenuName As Variant) As Long
Sub Example_ExecuteMenu()
sts = HypExecuteMenu("Sheet1", "Panel")  'returns 0
sts = HypExecuteMenu(Empty, "Smartview->Refresh") 'returns 0
sts = HypExecuteMenu("Sheet1", "Refresh")  'returns -73(ambiguity)
sts = HypExecuteMenu("Sheet1", "Connections")  'returns -15(invalid parameter because "Connections" is not associated with an action)
End Sub