How to Show or Hide Word Text When a Checkbox is Selected
Question details
The user wants to configure a Microsoft Word document so that specific text dynamically appears or disappears based on whether a checkbox is checked or unchecked.
- Product
- Microsoft Word 365
- Device & OS
- not provided
- Scenario
- Creating dynamic forms or interactive documents where certain text content needs to be hidden or displayed depending on user selections in a checkbox.
- Observed behavior
- This functionality requires the use of Content Controls linked to a VBA script, and the file must be saved as a macro-enabled document (.docm or .dotm) to work.
Ensure you have the Developer tab enabled in your Word ribbon, as you will need it to insert checkboxes and write the VBA code required for this functionality.
Use Content Controls and VBA to Toggle Text Visibility
This is the most reliable method for desktop versions of Word, utilizing Content Control checkboxes and a VBA macro to trigger the text visibility.
Please note that VBA macros do not run in Word for the web or mobile apps. For Mac users, ensure you are using Content Controls or legacy form fields, as ActiveX controls are completely unsupported on macOS.
Go to File > Options > Customize Ribbon. In the right pane, check the box next to 'Developer' and click OK.
Place your cursor where you want the checkbox to appear. Navigate to the Developer tab and click the 'Check Box Content Control' icon.
Select your newly inserted checkbox, click 'Properties' in the Developer tab, and assign it a unique Tag (for example, 'Check1').
Highlight the text you want to show or hide. Go to Insert > Bookmark, give it a name without spaces (e.g., 'HiddenText'), and click Add.
Press Alt + F11 to open the Visual Basic for Applications (VBA) editor. Double-click 'ThisDocument' in the left pane and write a Document_ContentControlOnExit macro that toggles the font's hidden property for your bookmark based on the checkbox's state.
Go to File > Save As, and choose 'Word Macro-Enabled Document (*.docm)' or 'Word Macro-Enabled Template (*.dotm)' from the format dropdown menu.
Create Dynamic Forms and Macros with WPS Office
WPS Office offers robust developer tools, including full VBA macro support and legacy form controls, allowing you to easily create interactive documents with dynamic text hiding capabilities.
- 1. Enable Developer Tools: Open WPS Writer, navigate to Menu > Options > Custom Ribbon, and ensure the Developer tab is checked.
- 2. Insert a Checkbox: Go to the Developer tab, click on 'Forms' or 'Content Controls', and select the Checkbox icon to insert it into your active document.
- 3. Write the Macro: Click 'Visual Basic' in the Developer ribbon to open the VBA editor and script your text visibility logic.
- 4. Save as .docm: Click Menu > Save As and select the macro-enabled format (.docm) to ensure your custom VBA scripts are preserved.

Frequently Asked Questions
Can I use ActiveX checkboxes on Word for Mac?
No, ActiveX controls are entirely unsupported on macOS. You should use Content Controls or Legacy Form Fields instead to ensure the document functions correctly across different operating systems.
Why isn't my VBA code running when I check the box?
Ensure that you have saved the document in a Macro-Enabled format (.docm) and that macros are allowed in your Trust Center settings. Additionally, check that the VBA script is assigned to the correct event, such as ContentControlOnExit, so it triggers when you interact with the checkbox.
Do checkbox macros work in Word for the web or mobile apps?
No, VBA macros are not supported in Word for the web or mobile applications. Users must open the document using a desktop version of Word for the dynamic text hiding script to execute.




