How to Create a Microsoft Word Form That Auto Hides Text When Checkbox Is Checked?

By Darrin Koltow

By learning to hide text when a Word form's checkbox is checked, you can let form users control large amounts of content in a document with a single click. The event function of Word's Visual Basic programming language makes this project possible. Event functions are functions that Word executes whenever a user interacts with a form control linked to your program. For example, the event function "Checkbox1_Clicked" will run when a user clicks the checkbox named "CheckBox1."

Step 1

Click the "File" menu's "New" command, then click "OK" to accept the default parameters for a new document. Click the "Developer" tab to display the "Controls" panel, which contains controls you can insert on your form.

Step 2

Click any control you'd like for the form, such as a text box or dropdown list. Word will add the controls you click to the form.

Step 3

Click the "Checkbox" control to add this control to the form, then type some text below the form. You'll write a program for the checkbox control that will hide this text.

Step 4

Drag the mouse over the text to select it, then click the "Insert" tab's "Bookmark" button. Type the name "TextToHide" for the bookmark, then click "Add" to link this name with the bookmark. This step names the bookmark so your program can easily identify which text to hide.

Step 5

Right click the checkbox control, and click the "View code" item to open the Visual Basic environment in which you'll write a program for the checkbox.

Step 6

Paste the following program into the window. This program reads the "Hidden" property of the text you bookmarked. If that property is set to "False," the text is not yet hidden. The program will set this property to true, which will hide the text.

Private Sub CheckBox1_Click()

If Bookmarks("TextToHide").Range.Font.Hidden = True Then

Bookmarks("TextToHide").Range.Font.Hidden = False


Bookmarks("TextToHide").Range.Font.Hidden = True

End If

End Sub

Step 7

Click the "Word" icon on the Windows taskbar to return to your Word form, then click the "Design mode" button of the "Developer" tab to activate the form for data entry.

Step 8

Click the checkbox. This action will run your program, which will hide the text you bookmarked. Click the checkbox again to reveal the text.