Syntax
CountMenuItems(Menu$, Type [, Context])
Remarks
Returns the number of menu items on the specified menu. Separators are counted as menu items. In several cases, a list of menu items is counted as one. You can identify these cases in the Position On Menu box on the Menus tab in the Customize dialog box (Tools menu). Examples include the list of filenames on the File menu, the list of windows on the Window menu, and the list of proofing tools on the Tools menu.
Argument | Explanation | |
Menu$ | The name of a menu or a shortcut menu. Menu names appear in the Menu list box, which is on the Menus tab in the Customize dialog box (Tools menu). Including an ampersand (&) before the underlined letter in the menu name is optional (for example, you can specify either "File" or "&File"). Do not include the parenthetical phrases "(No Document)" and "(Shortcut)" even though that text appears in the Customize dialog box. | |
Type | The type of menu: 0 (zero) Menus on the menu bar when a document is open 1 Menus on the menu bar when no document is open 2 Shortcut menus | |
Context | Specifies which menu items to count: 0 (zero) The items that are displayed on the menu when a document based on the Normal template is active 1 or omitted The items that are currently displayed on the menu Note that the items that are displayed on the menu depend on the custom settings, if any, of the active template, any loaded global templates, and the Normal template. |
Example
This example inserts a tab-delimited list of the menu items on the Tools menu in the active template:
tab$ = Chr$(9) For n = 1 To CountMenuItems("T&ools", 0, 1) Insert Str$(n) + tab$ + MenuItemText$("T&ools", 0, n, 1) InsertPara Next
See Also
MenuItemMacro$(), MenuItemText$()