Excel: Managing Check Marks in Custom MenusLast reviewed: October 31, 1994Article ID: Q47584 |
SUMMARYBecause CHECK.COMMAND is a toggle in Excel version 2.20, the simplest way to manage it is to keep a flag of its current status. Pick a variable or cell to hold one of two values determining the current check setting. Near the beginning of the macro, initialize the variable to the initial setting of the check mark. Note that this initializing process can be carried out only once, or the check is reset each time the macro is run.
MORE INFORMATIONA simple technique to ensure this process is to create a separate macro that initializes any menus and check marks as well as the flag variables controlling the check marks. The following is an example:
=SET.NAME("mybar",ADD.BAR()) ; Create a new menu bar named mybar =ADD.COMMAND(mybar,1,menu1) ; Add menu command #1 =ADD.COMMAND(mybar,2,menu2) ; Add menu command #2 =SET.NAME("check1",FALSE) ; Flag for check #1 set for off=RETURN() Once the menus have been initialized, add the following commands to the macro, which is executed when the item to be checked/ unchecked is run:
=SET.NAME("check1",NOT(check1)) ; Toggle the flag =CHECK.COMMAND(mybar,menu,command,check1) ; Set the checkNow, each time the Menu command in question is called, this macro is run and these two statements are executed. The first statement toggles the flag (if check1=FALSE then check1=TRUE and vice versa). The second statement actually sets/resets the check based upon the value of the flag.
|
KBCategory: kbother
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |