ENABLE.COMMAND macro

Enables or disables a custom command or menu. Disabled commands appear dimmed and can't be chosen. Use ENABLE.COMMAND to control which commands the user can click in a menu bar.

Syntax

ENABLE.COMMAND(bar_num, menu, command, enable, subcommand)

Bar_num    is the menu bar in which a command resides. Bar_num can be the number of a built-in menu bar or the number returned by a previously run ADD.BAR function. See ADD.COMMAND for a list of the built-in menu bar numbers.

Menu    is the menu on which the command resides. Menu can be either the name of a menu as text or the number of a menu. Menus are numbered starting with 1 from the left of the screen.

Command    is the command you want to enable or disable. Command can be either the name of the command as text or the number of the command. The top command on a menu is command 1. If command is 0, ENABLE.COMMAND enables or disables the entire menu.

Enable    is a logical value specifying whether the command should be enabled or disabled. If enable is TRUE, Microsoft Excel enables the command; if FALSE, it disables the command.

Subcommand    is the name of the command on a submenu that you want to enable. If you use subcommand, you must use command as the name of the submenu. Use subcommand 0 to enable an entire submenu.

Remarks

 

Example

The following macro formula disables a custom command that had been added previously to the View menu on the worksheet and macro sheet menu bar:

ENABLE.COMMAND(10, "View", "Audit...", FALSE)

Related Functions

ADD.BAR   Adds a menu bar

ADD.COMMAND   Adds a command to a menu

CHECK.COMMAND   Adds or deletes a check mark to or from a command

DELETE.COMMAND   Deletes a command from a menu

RENAME.COMMAND   Changes the name of a command or menu

Return to index