Browse » Home
Sunday, May 22, 2011
How to Create a Microsoft Word Form That Auto Hides Text When Checkbox Is Checked?
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.
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.
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.
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.
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.
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 ThenBookmarks('TextToHide').Range.Font.Hidden = FalseElseBookmarks('TextToHide').Range.Font.Hidden = TrueEnd IfEnd Sub
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.
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.