Office Settings & Configuration

How to Calculate the Percentage of Checked Word Checkboxes with VBA

Jason MillerJason Miller Nov 3, 2026 868 views

Question details

The user needs to calculate and display the percentage of selected checkboxes in a Word quality-control checklist using a VBA macro.

How to Calculate the Percentage of Checked Word Checkboxes with VBA
Product
Word Processing (Microsoft Word / WPS Writer)
Device & OS
not provided
Scenario
Creating a dynamic quality-control checklist document utilizing multiple simple legacy form-control checkboxes that must output a completion metric.
Observed behavior
The user requires an automated method via VBA where exiting a selected checkbox updates a calculated text form field with the current completion percentage.
Before you start

Ensure that the Developer tab is enabled in your word processor's ribbon, as you will need access to legacy form fields and the VBA editor to implement and assign the macro.

Solution 1Recommended

Use a VBA Macro for Legacy Form Field Checkboxes

Create a VBA macro that counts all legacy form fields, checks their true/false status, calculates the percentage, and outputs it to a designated text field upon exiting a checkbox.

This method requires your document to use legacy form controls (not ActiveX or Content Controls). You will assign this macro to run automatically whenever a user exits a checkbox, providing real-time percentage updates.

1
Insert the form fields

Insert your legacy checkbox form fields into the document layout. Then, insert a Legacy Text Form Field where you want the percentage to appear. Double-click this text field and set its Bookmark name to 'PercentageChecked'.

2
Open the VBA Editor

Press Alt + F11 to open the VBA Editor. Insert a new module by clicking Insert > Module from the top menu.

3
Write the macro code

Write a script that loops through 'ActiveDocument.FormFields'. Count the total number of CheckBox types and track how many have a '.CheckBox.Value' of True. Calculate the percentage (Checked / Total * 100) and assign the formatted result to 'ActiveDocument.FormFields("PercentageChecked").Result'.

4
Set the macro to run on exit

Return to your document view. Double-click each checkbox to open its properties dialog, locate the 'Run macro on exit' dropdown, and select the macro you just created. Finally, protect the document for 'Filling in forms' to activate the logic.

Use a VBA Macro for Legacy Form Field Checkboxes
Macro Security and Document Format: Make sure to save your document as a Macro-Enabled Document (.docm) and ensure macro execution is permitted in your Trust Center settings for the calculation to run.
Automate Document Workflows

Create Automated Checklists Easily with WPS Writer

WPS Writer provides robust, built-in support for legacy form fields and VBA macros, allowing you to seamlessly construct automated quality-control checklists that calculate dynamic percentages in real-time.

  1. 1. Enable the Developer Tab: Open WPS Writer, go to Options > Customize Ribbon, and check the 'Developer' box to reveal form controls.
  2. 2. Insert Checkboxes: Navigate to the Developer tab, select Legacy Forms, and insert Check Box Form Fields into your checklist.
  3. 3. Add the VBA Script: Click 'Macros' in the Developer tab, create a new macro for your calculation, and paste your VBA percentage logic.
  4. 4. Apply Exit Macro: Double-click your checkboxes and configure the 'Run macro on exit' option to execute your script automatically.
Full compatibility with Microsoft Word macro-enabled documents (.docm)Built-in VBA editor for seamless macro creation and script debuggingEasily insert and configure legacy form fields via the Developer ribbonLightweight application with a familiar, user-friendly interface
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't my checklist percentage updating automatically?

The macro must be strictly assigned to the 'Exit' event of each checkbox. Double-click the checkbox to open its properties dialog and ensure the 'Run macro on exit' dropdown is set to your calculation macro.

Does this calculation macro work with Content Control checkboxes?

No, this specific VBA logic relies on iterating through Legacy Form Fields. Content controls require a different VBA approach using the Document_ContentControlOnExit event instead.

How do I ensure users can check the boxes without altering the text?

You need to protect the document. Go to the Developer tab, select Restrict Editing, check the editing restrictions box, and set the dropdown to 'Filling in forms'.