Command BeforeExecute

The CommandBeforeExecute event occurs when a user selects a command from the menu bar or toolbar but before the action associated with the command takes place. You can use this event to cancel the command selected or to impose certain restrictions before a command is executed. This event takes the following two arguments:

Command — Returns a PivotCommandId constant and allows you to determine which command the user wishes to execute. You can use the Object Browser to view the list of commands for this constant. Cancel — Returns an object. By setting the Value property of this argument to True, the specified command will not be executed.

The event procedure in Hands-On 24-33 demonstrates how to prevent the user from executing the AutoFilter command.

0 0

Post a comment