|
|
The information in this website is provided without risk or
obligation and free of charge. However, if you have benefitted
from my efforts here and would like to make a contribution to
help me continue and maintain this work then any donation will
be greatly appreciated. Please click the adjacent button to
access PayPal. Thank you.
|
|
This Microsoft Word Help and Tips Page shows you how you can incorporate interactive
check boxes in unprotected Word documents. The process involves creating a
pair of AutoText entries consisting of a MACROBUTTON field that displays a
symbol (a cleared or a checked box) and applying a few simple macros that will
run when you double-click the displayed symbol to toggle between the two
symbols. As an alternative you might prefer a cleared box and
a "x" marked box or any any symbol pair (see the examples below). |
|

|
|
1. Open a new blank document. Just to make things easier, save it now
with any name. You can delete it later when finished with this process.
Next, if not already displayed, use the
View>Toolbars menu to display the Format toolbar. In the Style window,
type Checkboxes and press enter. This creates a style, but more
importantly in this case it creates a category in Autotext to hold your checkbox
symbol entries.
Bonus Tip: AutoText categories are simply a list of
styles where one or more AutoText entry has been created with that style
applied. |
|

|
|
2. Without moving the cursor, Press CTRL+F9 to enter field code delimiters "{
}." In the delimiters type "MACROBUTTON Checkit " then use the
Insert>Symbol menu to insert a clear box. See illustrations below: |
|

|
|

|
| 3. Now define the first Autotext entry.
Select the entire field code (do not select the paragraph mark at the end of
the field) and press ALT+F3. This opens the "Create AutoText" dialog
box. Name the AutoText entry "Unchecked Box" as shown below and press
"OK." Tip: You might want to display
non-printing characters (CTRL+SHIFT+*) to make it easier to select just the
field code. |
|

|
| 4. Now define the second AutoText entry.
Using the
keyboard and Insert>Symbol menu, change the field code as shown below. Then
select the revised field code and press ALT+F3. Name this AutoText entry
"Checked Box." Tip: You can choose the "X'd" box at this point if
you prefer. |
|

|
|

|
|

|
| 5. You have now created two AutoText
entries. One displays a cleared box and one displays a checked box. As you have seen
from the construction these symbols are nested in a MACROBUTTON
field. One field fires a macro labeled "Checkit" and the other field
fires a macro labeled "Uncheckit." The next step is to create these two macros
that make the
symbols interactive. 6. Macros tell Word to do something when they
are fired. In our case we want Word to replace a cleared box with a
checked box when the macro labeled "Checkit" is fired and replace a checked
box with a cleared box when the macro labeled "Uncheckit" is fired.
The required macros are provided below. Applying macro code to your
VBA project is beyond the scope of this page. If you are unfamiliar
with this process please see fellow MVP Graham Mayor's
Guide for
Installing Macros. |
| |
Sub CheckIt()
ActiveDocument.AttachedTemplate.AutoTextEntries("Checked Box").Insert
Where:=Selection.Range
End Sub
Sub UncheckIt()
ActiveDocument.AttachedTemplate.AutoTextEntries("Unchecked Box").Insert
Where:=Selection.Range
End Sub |
| 7. With the macros placed in the VBA Project of your
template you are ready to start using your new interactive checkboxes. Before you do, be sure
that you save the changes that have been made to your
template. Hold down the SHIFT key and select File>Save All. Save All
will ensure the AutoText and macro entries in your template are saved.
Or if you have your system setup to prompt you of any changes to your
template then answer yes to the prompt. |
|

|
|
| 8. Your Insert>AutoText Menu now has a new
category named "Checkboxes." Select this category whenever you want
to place an initially checked or unckecked box in your document. |
|

|
| 9. Like any AutoText entry, the checked or
unchecked box can be inserted as you type when your system is configured to
"Show AutoComplete Suggestions." Simply begin typing check.. or
unche.. and when the AutoComplete tip appears press enter. |
|

|
| 10. Go ahead and enter a few and give it a
try. Viola, your boxes are interactive!! Bonus
Tip: You can use VBA to interpret the setting of your toogle objects
by evaluating the underlying field code. For example, a Checked Box
toggle could be evaluated with VBA as follows:
If Mid$(ActiveDocument.Fields(1).Code, 14, 7) =
"Uncheck" Then
|
11. If you are not up to the task of
creating your own checkboxes then I have done it for you (I was bored
).
The following file provides templates (Word2003 and Word2007) contain all the Autotext
entries, macros, and toolbar/ribbon customization to create the interactive
toogles:
Toggle
Objects.zip
|
|

Word 2003 |
|
|

Word 2007 |
|
12.
Unzip the file to your Word>Startup directory so it
will load as a global template making the AutoText entries, macros, and
toolbar available in all your Word documents. You can click on
Installing an Using Global Addins if you need help or further
explanation on using templates and addins. 13. A disadvantage of the
technique shown above is that the toggles won't work if you send the
document someone that doesn't have the underlying template containing the
AutoText entries. You can resolve this by sending the template with
the document with instructions to the user, or you can send a document
containing VBA that will create toggles on the fly. The following code uses an AutoOpen macro to create a checked and
unchecked box AutoText entry in the attached template when the document is opened on another users
computer.
Note:
The recipient of you document will have to enable the macro when opening the
document.
Sub AutoOpen()
Dim oDoc As Word.Document
Dim oTemplate As Template
Set oTemplate = ActiveDocument.AttachedTemplate
Dim pName As String
pName = oTemplate.FullName
'Open a temporary document to serve as a
scrathpad
Set oDoc = Documents.Add(Template:=pName,
Visible:=False)
'Use the scratchpad to create a pair of
AutoText entries in the attached template
With Selection
'Create the empty box
AutoText entry
.Fields.Add Range:=.Range,
Type:=wdFieldEmpty, _
PreserveFormatting:=False
.TypeText Text:="MacroButton CheckIt"
.MoveRight Unit:=wdCharacter, Count:=1
.InsertSymbol Font:="Wingdings", CharacterNumber:=-3985, _
Unicode:=True
.SetRange Start:=0, End:=1
.Fields(1).ShowCodes = False
oTemplate.AutoTextEntries.Add Name:="Unchecked Box on the
Fly", Range:=.Range
.Delete
'Create the checked box AutoText
entry
.Fields.Add Range:=.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
.TypeText Text:="MacroButton UncheckIt"
.MoveRight Unit:=wdCharacter, Count:=1
.InsertSymbol Font:="Wingdings", CharacterNumber:=-3842, _
Unicode:=True
.SetRange Start:=0, End:=1
.Fields(1).ShowCodes = False
oTemplate.AutoTextEntries.Add Name:="Checked Box on the Fly",
Range:=.Range
.Delete
End With
'Crumple up and kill the scratchpad
oDoc.Close wdDoNotSaveChanges
Set oDoc = Nothing
'Clean up
oTemplate.Save
oTemplate.Saved = True
Set oTemplate = Nothing
End Sub
Sub CheckIt()
ActiveDocument.AttachedTemplate.AutoTextEntries("Checked Box on the
Fly").Insert _
Where:=Selection.Range
End Sub
Sub UncheckIt()
ActiveDocument.AttachedTemplate.AutoTextEntries("Unchecked Box on the
Fly").Insert _
Where:=Selection.Range
End Sub
|
|
|
Looking for something else? |
|
|
|
|
|
|
|