How to create CheckBoxes in Word 2007 without using the ActiveX or Legacy Forms checkbox!

So you think you are stuck with using that lovely ActiveX checkbox for your document. The way most people thought, I would have figured you were stuck with it too. The other alternative, the Legacy Forms checkbox, is rarely viable as you have to protect the document. That means no edits, which is a whole new pain.

Well, what’s wrong with the ActiveX checkbox you ask? Not much, if you don’t mind extreme document load times when you have a large number of them. Also if you don’t mind lugging around the ActiveX baggage and security issues that come with them. Plus the conversion issues when displaying them online.

So, what is the solution? It is much simpler than you would think. I have seen some complex solutions that people have employed with Templates and other nonsense. Those require you to give that template to the end reader and is just kludgy.

I have a simpler approach. A very short macro and the use of Fields, which in turn I use at MacroButtons. Simple, yes. Effect, yes.

Think outside the box Smile

Here is the how to:

Create a Macro named CheckMe in your document.

image

Paste this code into it:

Sub CheckMe()

‘ CheckMe Macro


”MsgBox “clicked”
Dim f As Field
”254 is check box
”168 is unchecked
For Each f In Selection.Fields
f.Code.Font.Name = “WingDings”
If (f.Code.Text = “MACROBUTTON CheckMe ” + Chr(111)) Then
f.Code.Text = “MACROBUTTON CheckMe ” + Chr(254)
Else
f.Code.Text = “MACROBUTTON CheckMe ” + Chr(111)
End If

Next

End Sub

image

Now you have it setup to handle the new field.

Time to add the field. After you add one, it is super simple to add more. All you will to do is copy and paste.

Add our Macro Field aka our CheckBox.

I made this really easy for you so you don’t need to lookup symbols or any of that jazz.

Step 1  – Click Insert –> Quick Parts –> Field

image

Step 2 – Data Entry

Select MacroButton from Field names.

Enter Display Text of BOX

Select CheckMe from MacroName list

Hit OK

image

But now I have the word box? That’s not a check box! You fooled me!

image

Well, I said I was making it easier on you. Click the word! Voila. Like magic, it is now  a check box.

image click again

image

Yeah! Checkbox.

You can copy and paste this to where you want, or go through the steps again. Copy and paste is easier.

I have attached a working Word 2007 document to example the alternative checkbox technique.

Happy coding!

Example of not using checkboxes

0 Replies to “How to create CheckBoxes in Word 2007 without using the ActiveX or Legacy Forms checkbox!”

  1. I followed these instructions but when I doubleclick on the word BOX it just opens up the Macro code. (coder status = Novice) 🙂

  2. Let me preface this comment by stating that its been a very long time since I created macros, so this your instructions seem alittle foreign.

    I followed these instructions, but nothing comes up–no BOX is reflected for me to double click. What am I doing wrong?

    1. Under my text Happy Coding, there is a link to a sample document. Open that up and see if that works for you. If so, then it can help serve as some guidance for doing it in your own document.

  3. I did all this and got an error when I clicked the BOX!! Sounds gud though, pls help!
    “Compile Error: Sub or Function not defined.”

    1. Make sure the VBA code is correct. Does it look like the picture? Also, try downloading the file I attached and comparing yours to it. The link is under the words “Happy Coding”.

  4. This is awesome – thanks very much! Activex boxes were KILLING the size of my document.

    One question, how would one distribute this macro with the document to be used on multiple workstations? For my use with a legacy app calling MS Word it has to be in a .doc format.

  5. I got the same error as Ben. The reason I wanted to do this is b/c the legacy check boxes I entered simply do not work. The user can not check them! They can edit the text fields, but not check boxes – even if the sheet is unprotected.

  6. For everyone getting the “Compile Error: Sub or Function not defined.” error:

    Click on Brian’s image above of the picture of the code in the macro editor, and examine it real close. I found that pasting the code in from the article above messed up the quotes. Try re-typing in all the quotes in the macro editor so they are straight quotes. Also, notice that the quotes before MsgBox are two single quotes in the picture, not a double quote.

    Fixing those cleared up the error for me. Thank you so much Brian! Genius solution.

    1. Good find. Didn’t think about the fact that WordPress doesn’t seem to like when I post code. Haven’t figured out to do it cleanly as it mucks up certain characters.

      I also put an attachment at the end of the post called Example…. You can just grab the code out of there as well for the copy and paste folks. Happy coding!

  7. Hi, I used your CheckMe macro to use in one of the forms that i had to build at work.

    I have never leant any software programs,and managed to create the form only based on the aritcles on the internet…

    The form is done now, however, when i protect the document, it gives me a run time error 4605. how do i tackle it…

    I have used the developer tab (legacy tools) for the rest of the document as well

    1. If you protect the document, the contents may not be modifiable and you will get an error.
      One possible solution, if you need the document protected, is to unprotect the document in the macro, change the character, then protect the document.

      i.e.

      unprotect ”
      do work
      protect ”

  8. Wow, thanks! Very helpful. I was having issues with the copy/paste of the code, but I re-typed it just how it was in the image and worked great, i could make the larger, copy and paste the check boxes. Wonderful!

  9. I tried this. After some trouble with delimiters, i got it to compile and run correctly, but the ASCII numbers are giving me some different characters than those shown…changing 111 to 110 gives “n” instead of “o” for example

  10. Hello Brian;

    I saw your post on Checkboxes by using the Code below. I have inserted it and followed the remaining directions. I continually get either a Compile Error or Can’t evaluate code in break Mode, Any ideas what is going wrong?
    Thanks’

    Gordon

    Sub CheckMe()

    ‘ CheckMe Macro


    ”MsgBox “clicked”
    Dim f As Field
    ”254 is check box
    ”168 is unchecked
    For Each f In Selection.Fields
    f.Code.Font.Name = “WingDings”
    If (f.Code.Text = “MACROBUTTON CheckMe ” + Chr(111)) Then
    f.Code.Text = “MACROBUTTON CheckMe ” + Chr(254)
    Else
    f.Code.Text = “MACROBUTTON CheckMe ” + Chr(111)
    End If

    Next

    End Sub

    1. My guess, I have seem some issue with smart quotes. Redo all the quotes by hand. i.e. delete the quote, then retype it. The blog, and browsers, try to be fancy when code editors do not appreciate fancy at all.
      Happy Coding!

  11. I actually think I have made this work. Thanks for providing an alternative method to legacy checkboxes. I encountered all the same issues others have.

    I do have one question . . . is there a way to make the checkbox and checkmark larger? I have dressed up my document using tables and put the checkbox ina table cell. Is the size of the table cell controlling the size of the checkbox?

    Thanks in advance!

  12. Hi there….I am trying to have three things happen…the default is a blank box, click once and it’s a checkmark, click again it’s an X, click again it’s a blank and so on.
    Is there any way this can be done?
    Thanks in advance!

  13. having trouble with this code:

    Unprotect ”
    do work
    Protect ”

    can you show me an example in a document so i can see exactly where to place it and exactly what the quotations look like. PS great short cut to the activeX contols! can we create a keyboard short cut?

    1. Basically, the quotes are there for the password. If you are using a more advanced protect, i.e, protecting specific types of edits, then I would checkout the vba api documentation on the Protect call for Excel.

      The do work, well, that just short for everything in the function.

      i.e. put the unprotect at the top of the function, and the protect at the bottom.

      I hope that helps a bit. If you guys need a custom solution, feel free to contact SeekfordSolutions.com .

  14. Brian, I created the checkme macro and it worked perfectly. I tried to open it up on another computer to test it, and the checkboxes aren’t working? Do I need to change a setting?

      1. Created the macro, verified the code, works great on my computer, but not on anyone elses. I made sure the macro was written in the normal.docm (macro-enabled document) and not a template, but the macro is still not portable when I email this to anyone.

        1. I ended up creating a work around by putting in a drop down menu with Wingdings characters that are either an empty box (lowercase o), or a box with an X (lowercase x) in it.

          1. Clever way of handling it. The Macro issue is pretty easy to screw up. It is easy to accidentally edit the Normal template and have it only work on your computer.

  15. When I click on the word BOX nothing happens, I double click and Visual Basic appears with the wording
    Compile error: Syntax error on the line “MsgBox “clicked”

    How do I correct this?

  16. Hello! This tutorial is Awesome! I had it working in under 5 minutes.
    I was wondering, is there a way to change the character that shows up when you click the box?
    I would love to have it show up as just a checkmark or “X”. I tried changing the Chr(), but instead ended up with a “x” inside a box.
    I don’t code at all so hopefully there is an easy solution- I wouldn’t know yet 🙂

    Thanks so much!

    1. Just lookup the character code for the symbol you want to use. You can use anything. I pulled the chars from WingDings since it is a symbol font. You could technically make it show happy faces and sad faces for the different states. That would look pretty cool 🙂

  17. I tried to use this code in an Outlook email and got the error message “Compile Error: User Defined Type Not Defined”, and when the error came up, it highlighted “f As Field”

    Can you help me figure this out? It would be great to find a way to have a check box in my Outlook Email Template.

  18. Hello. This is an excellent tutorial! I’ve created numerous forms in Word 2007 recently and checkboxes seem to be more popular than ever. Microsoft’s Legacy/Active-X checkbox solutions are cumbersome; but your approach is elegantly simple. Thanks for sharing your work with others. We really appreciate it!

Leave a Reply

Your email address will not be published. Required fields are marked *