Data provider types: All
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).
HypExecuteMenu (vtSheetName, vtMenuName) As Long
ByVal vtSheetName As Variant
ByVal vtMenuName As Variant
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.
For items that are displayed on multiple ribbons or menus, you must prepend the ribbon title (Office 2007 or later) to the item name using the characters -> to avoid ambiguity. For example, to distinguish between Refresh on the Smart View ribbon and Refresh on the Essbase ribbon, use Smart View->Refresh or Essbase->Refresh. Duplicate items within the same data provider or extension ribbon cannot be used.
Only items associated with an action are supported. For example, Panel can be used, because it opens the Smart View Panel. Connections cannot be used, because it is not associated with an action.
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”).
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