How to Automatically Check Related Word Checkboxes with VBA
Question details
The user wants a master checkbox in a Word document to automatically select or clear multiple dependent checkboxes throughout the same document.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Creating dynamic forms or templates in Word where selecting one master option automatically selects associated sub-options.
- Observed behavior
- By default, checkboxes must be ticked individually. The goal is to synchronize the checked state of multiple slave checkboxes with a single master checkbox using VBA.
Ensure that your Word document is saved as a Macro-Enabled Document (.docm) and that the Developer tab is enabled in your ribbon to access Content Controls and the VBA editor.
Use VBA ContentControlOnExit Event to Synchronize Checkboxes
Assign specific tags to your master and slave content control checkboxes, then use VBA to sync their states when the master checkbox is clicked and exited.
This solution relies on Word's built-in Content Controls. By assigning a common tag to all the slave checkboxes, a short VBA macro can locate them and match their checked status to the master checkbox.
Go to the Developer tab on the Word ribbon. Click the 'Check Box Content Control' icon to insert a checkbox for your master item, and repeat this to insert checkboxes for all related slave items.
Select the master checkbox, click 'Properties' in the Developer tab, and type 'Master1' in the Tag field. Next, select each of the related slave checkboxes, open their properties, and set their Tag field to 'Master1_Slave'.
Press 'Alt + F11' on your keyboard to open the Visual Basic for Applications (VBA) editor. In the Project Explorer pane on the left, double-click on 'ThisDocument' to open the document's code window.
Paste the following code into the 'ThisDocument' module: Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim controls As ContentControls Dim control As ContentControl If ContentControl.Tag = "Master1" Then Set controls = ActiveDocument.SelectContentControlsByTag("Master1_Slave") For Each control In controls control.Checked = ContentControl.Checked Next control End If End Sub
Close the VBA editor and return to your document. Click the 'Master1' checkbox to change its state, then click anywhere outside of the checkbox (to trigger the exit event). The 'Master1_Slave' checkboxes will automatically update to match.

Try WPS Office for Seamless Document Management
If you frequently work with documents but find Microsoft Office too heavy or expensive, WPS Office provides an incredibly lightweight, free, and highly compatible alternative for your daily document processing, form creation, and editing needs.
- 1. Download and Install: Visit the official WPS website to download the free, lightweight installer for your Windows, Mac, or Linux device.
- 2. Open Your Document: Launch WPS Writer and open your existing Word document. WPS seamlessly retains your original formatting and layouts.
- 3. Explore Free Features: Enjoy built-in PDF tools, rich formatting options, and cloud collaboration without needing a premium subscription.

Frequently Asked Questions
Why aren't my slave checkboxes updating immediately when I click the master checkbox?
Because the code uses the `Document_ContentControlOnExit` event, the macro only executes when the cursor leaves (exits) the master checkbox. Click anywhere outside the master checkbox to trigger the code and see the update.
Can I use Legacy Form Fields instead of Content Controls?
Yes, you can use Legacy Form Field checkboxes, but the VBA required is completely different. You would need to write a macro that runs on the 'Exit' property of the legacy checkbox to update the `.Result` values of the other form fields.
How do I add the Developer tab to use Content Controls?
In Microsoft Word, go to File > Options > Customize Ribbon. Check the box next to 'Developer' in the right-hand column under Main Tabs, then click OK. The tab will now appear on your ribbon.
Will this VBA code work on macOS?
Content Controls have limited support and differing behaviors in Word for Mac depending on the specific version. For cross-platform compatibility across Windows and Mac, it is often safer to use Legacy Form Fields.




