logo
search
VBA & Macro Problems

How to Automatically Check Related Word Checkboxes with VBA

Ayan MasoodAyan Masood Sep 28, 2026 870 views

Question details

The user wants a master checkbox in a Word document to automatically select or clear multiple dependent checkboxes throughout the same document.

How to Automatically Check Related Word Checkboxes with VBA
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.
Before you start

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.

Solution 1Recommended

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.

1
Insert Content Control Checkboxes

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.

2
Assign Tags to the Checkboxes

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'.

3
Open the VBA Editor

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.

4
Insert the Macro Code

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

5
Test the Synchronized Checkboxes

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.

Use VBA ContentControlOnExit Event to Synchronize Checkboxes
Triggering the Macro: The macro relies on the OnExit event. This means the related slave checkboxes will only update after you check or uncheck the master box and then move your cursor or click elsewhere in the document.
Free Microsoft Office alternative

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. 1. Download and Install: Visit the official WPS website to download the free, lightweight installer for your Windows, Mac, or Linux device.
  2. 2. Open Your Document: Launch WPS Writer and open your existing Word document. WPS seamlessly retains your original formatting and layouts.
  3. 3. Explore Free Features: Enjoy built-in PDF tools, rich formatting options, and cloud collaboration without needing a premium subscription.
Fully compatible with Microsoft Office formats, including .doc, .docx, and macro-enabled .docm files.Lightweight alternative that supports robust form field creation, content controls, and template management.Free to use with a familiar, easy-to-navigate interface that requires zero learning curve.Includes built-in PDF editing and format conversion tools at no extra cost.
microsoft office alternative - wps office

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.