none
How do you reference a checkbox value in a table formula in MS Word? RRS feed

  • Question

  • I want do be able to tell if a checkbox is checked and then set an appropriate value in a word table.  How can this be accomplished?
    Monday, June 24, 2013 6:20 PM

Answers

  • This is strange... I know I posted an answer to this a couple of days ago, but it seems to have disappeared <sigh> And I didn't save the test document.

    It's possible, but not straightforward. I hope I can remember the steps accurately:

    1. Click on the tab of the checkbox content control, to select the entire content control

    2. Insert/Bookmark and add a bookmark for the control

    3. Click where you want to test the checkbox. Press Ctrl+F9 to insert a pair of field brackets. Type:
        [space]IF[space]"

    4. Ctrl+F9 and in the new pair of field brackets type: [space]REF[space][BookmarkName]

    5. Move the cursor to just after the closing Ref field bracket and type: "="

    6. Insert a checkbox content control

    7. Position the cursor just after/outside the checkbox and type: "[space]"True value"[space]"False value"[space]

    8. Press Alt+F9 to toggle from field code to field result. Press Ctrl+A, F9 to update the field codes in the document.

    Note: where you see square brackets, do not type these nor their content; instead, type the meaning. For example, where you see [space] press the Spacebar.


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, June 29, 2013 6:48 AM
    Moderator

All replies

  • 1. Which version of Word?

    2. What kind of checkbox is this? Formfield, ActiveX, Content control, something else?

    Are you looking for a macro solution or some other way of doing this?

    Please provide an example of "appropriate" and non-appropriate values that should be set.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, June 25, 2013 12:47 PM
    Moderator
  • 1. Word 2010 2. Content Control I would like to avoid a macro solution. My intent right now is based on the checkbox (if checked) to perform a calculation in one cell and provide text in other cells. If checkbox is not checked, then those cells would be left blank and/ or contain alternative text. Thanks for your help.
    Tuesday, June 25, 2013 9:12 PM
  • This is strange... I know I posted an answer to this a couple of days ago, but it seems to have disappeared <sigh> And I didn't save the test document.

    It's possible, but not straightforward. I hope I can remember the steps accurately:

    1. Click on the tab of the checkbox content control, to select the entire content control

    2. Insert/Bookmark and add a bookmark for the control

    3. Click where you want to test the checkbox. Press Ctrl+F9 to insert a pair of field brackets. Type:
        [space]IF[space]"

    4. Ctrl+F9 and in the new pair of field brackets type: [space]REF[space][BookmarkName]

    5. Move the cursor to just after the closing Ref field bracket and type: "="

    6. Insert a checkbox content control

    7. Position the cursor just after/outside the checkbox and type: "[space]"True value"[space]"False value"[space]

    8. Press Alt+F9 to toggle from field code to field result. Press Ctrl+A, F9 to update the field codes in the document.

    Note: where you see square brackets, do not type these nor their content; instead, type the meaning. For example, where you see [space] press the Spacebar.


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, June 29, 2013 6:48 AM
    Moderator
  • Not sure if this is meaningful to anyone else but I had to go ahead and select (i.e., "check") the checkbox control inserted in step 6 before going to step 7 for this to work correctly. 

    It wasn't clear to me above that this was necessary.

    Please note that I'm using the "@" symbol below to indicate the checked checkbox control.  (I could not get the code editor to work properly)

    { IF {REF MYBOOKMARK}=@ "CHECKED" "NOT CHECKED" }

    Tuesday, October 15, 2013 11:18 PM
  • Hello, This was very helpful for me. 

    Is there a way to change it so that it updates the result when the box is checked or unchecked?

    Right now it only returns the value once. 

    Thank You

    Tuesday, August 26, 2014 2:46 PM
  • Hi Joseph

    <<Is there a way to change it so that it updates the result when the box is checked or unchecked? >>

    No, not on check/uncheck as a content control does not have an event for that. You can assign macro code to the EXIT event (fires when the user moves the selection outside the content control. You can put code in a macro that will update the fields in the document.

    The reason it requires a macro is that Word does not update fields automatically during a Word session, except in certain instances. For example, if the matching option is activated, fields can be forced to update when you print (and will partially update in print preview, in certain versions of Word). But in order to get fields to update during normal editing process user action or macro code is required.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, August 27, 2014 2:43 PM
    Moderator