XLL+ Class Library (6.3)

CXlMenu::GetCallingMenu

Determine which menu item called the current add-in function

static BOOL GetCallingMenu(
   int& nBar,
   int& nMenu,
   int& nItem,
   int& nSubItem
);

Parameters

nBar

The index of the menu bar to which the menu item belongs. Note that the index of the Excel main application menu bar is 10.

nMenu

The index of the menu within the bar. Note that the index of the first menu is 1.

nItem

The index of the item in the menu. Note that the index of the first item is 1. If the function was called from an item on a sub-menu, then nItem will contain the index of the sub-menu in the main menu.

nSubItem

The index of the item in a sub-menu. If the item was not part of a sub-menu then this will contain 0, and should be ignored. Note that the index of the first item is 1.

Return Value

Returns TRUE if the current add-in function was called from a menu, FALSE if not.

Remarks

If the current add-in function was called from a menu item, this static function returns TRUE and sets the values of the nBar, nMenu, nItem and nSubItem arguments.

Requirements

Header: xlmenu.h

See Also

CXlMenu Class | CXlMenu Methods