How to Show a VBA Message Box for Two Checkboxes in Word
Question details
The user needs to validate two checkboxes within a Word UserForm, displaying a warning message and disabling the execute button if neither checkbox is selected.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Creating a UserForm dashboard in Word where users are required to select at least one of two specific checkboxes before they can proceed with document generation.
- Observed behavior
- The form must dynamically check the status of CheckBox15 and CheckBox16, warn the user via a MsgBox if both are blank, and prevent execution by toggling the CommandButton's enabled state.
Ensure your Word document is saved as a Macro-Enabled Template (.dotm) while developing, and verify the exact names of your checkbox and button controls in the Visual Basic Editor (VBE) properties.
Validate Checkboxes and Control Button State Using VBA
Use a custom validation subroutine triggered by exit events to evaluate the status of both checkboxes and update the form accordingly.
To ensure users make a valid selection before proceeding, you can disable the Execute button by default and only enable it once the required checkboxes are clicked. Using the _Exit event allows the validation to happen as soon as the user finishes interacting with the checkbox.
Open the Visual Basic Editor (ALT + F11), select your CommandButton in the UserForm, and change its 'Enabled' property to 'False' in the Properties window.
In your UserForm's code, create a new sub named 'Validate'. Use an IF statement: 'If Not CheckBox15 And Not CheckBox16 Then'. Inside this condition, add 'MsgBox "Your warning text"' and 'CommandButton1.Enabled = False'. In the Else block, add 'CommandButton1.Enabled = True'.
Generate the '_Exit' event for both CheckBox15 and CheckBox16 (e.g., 'Private Sub CheckBox15_Exit...'). Inside both of these event procedures, simply type 'Validate' to call your custom subroutine.
For added reliability, you can also call the 'Validate' subroutine in the '_Enter' event of the subsequent control the user is likely to click next.

Configure Form Loading and File Saving for New Documents
Ensure the UserForm only opens when creating a new document, and prevent it from reappearing when the finalized document is reopened.
Try WPS Office for Seamless Document Management
If dealing with complex VBA macros and UserForms in Microsoft Word is slowing you down, consider switching to WPS Office. It provides a highly compatible, intuitive alternative for processing standard documents and forms without the steep learning curve.
- 1. Download WPS Office: Visit the official WPS website and install the free version of WPS Office.
- 2. Open Your Document: Launch WPS Writer and open your standard Word documents or templates instantly.
- 3. Edit and Save: Use the intuitive editing tools to finalize your work and save it in standard formats like .docx.

Frequently Asked Questions
Why does my UserForm dashboard reappear when I reopen the saved document?
If your document was saved as a macro-enabled file and uses an 'Auto_Open' macro, the form triggers on every open. Change the macro to 'Auto_New' so it only runs upon initial creation, and save the finalized output as a standard .docx file to remove the macros.
How do I trigger VBA code as soon as a user clicks a checkbox?
You can use the CheckBox's `_Exit` or `_Click` event in the Visual Basic Editor. The `_Exit` event is highly recommended for validation, as it executes the moment the user tabs away or clicks into another form control.
Can I disable a command button until certain conditions are met?
Yes. Set the CommandButton's 'Enabled' property to False by default. Once the user satisfies your required conditions (like checking a specific box), you can use VBA logic to set `CommandButton1.Enabled = True`.




