logo
search
Document Editing Problems

How to Show or Hide Word Text When a Checkbox is Selected

Maira MehtabMaira Mehtab Sep 22, 2026 871 views

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.
Before you start

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.

Solution 1Recommended

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.

1
Enable the Developer Tab

Go to File > Options > Customize Ribbon. In the right pane, check the box next to 'Developer' and click OK.

2
Insert a Checkbox Content Control

Place your cursor where you want the checkbox to appear. Navigate to the Developer tab and click the 'Check Box Content Control' icon.

3
Assign a Tag to the Checkbox

Select your newly inserted checkbox, click 'Properties' in the Developer tab, and assign it a unique Tag (for example, 'Check1').

4
Bookmark the Target Text

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.

5
Add the VBA Code

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.

6
Save as a Macro-Enabled Document

Go to File > Save As, and choose 'Word Macro-Enabled Document (*.docm)' or 'Word Macro-Enabled Template (*.dotm)' from the format dropdown menu.

Macro Security Warning: Anyone opening this document will need to click 'Enable Content' in the security warning bar at the top of the screen to allow the macros to run.

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. 1. Enable Developer Tools: Open WPS Writer, navigate to Menu > Options > Custom Ribbon, and ensure the Developer tab is checked.
  2. 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. 3. Write the Macro: Click 'Visual Basic' in the Developer ribbon to open the VBA editor and script your text visibility logic.
  4. 4. Save as .docm: Click Menu > Save As and select the macro-enabled format (.docm) to ensure your custom VBA scripts are preserved.
Fully supports VBA macros for advanced document automation.Seamlessly compatible with Microsoft Word macro-enabled formats (.docm, .dotm).Features built-in Developer tools for quickly inserting checkboxes and content controls.Lightweight software with a familiar interface, ensuring zero learning curve.
microsoft office alternative - wps office

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.