Excel: Managing Check Marks in Custom Menus

Last reviewed: October 31, 1994
Article ID: Q47584

SUMMARY

Because 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 INFORMATION

A 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 check

Now, 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
KBSubcategory:

Additional reference words: 2.20 3.00


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 31, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.