logo
search
Document Editing Problems

How to Count Words in Selected Parts of a Word Document

Huda QurayshiHuda Qurayshi Oct 13, 2026 869 views

Question details

The user wants to count the total words only in specific, designated sections of a Word document while excluding elements like the cover page, headings, and appendices, and dynamically display this total.

How to Count Words in Selected Parts of a Word Document
Product
Word
Device & OS
not provided
Scenario
Tracking exact word counts for specific document sections without manually highlighting them each time, usually for assignments or professional reports with strict length constraints.
Observed behavior
Needs a dynamic, automated method using content controls and document variables to accurately calculate and display the targeted word count on the cover page.
Before you start

Ensure you have the Developer tab enabled in your Word processor's ribbon, as you will need access to Content Controls and the VBA Editor to automate this process.

Solution 1Recommended

Use Content Controls and VBA to Count Specific Sections

Use this method to automatically calculate words from designated text areas and display the result dynamically on a cover page.

By tagging specific content controls and using a simple VBA script, you can exclude unwanted sections (like tables of contents or references) from your total word count.

1
Insert Content Controls

Navigate to the Developer tab. Insert a Plain Text Content Control on your cover page and assign it the title 'Total'. Then, wrap the specific text sections you want to include in the word count with their own Content Controls.

2
Assign Tags to the Controls

Select the properties for the Content Controls surrounding your targeted text. Assign the exact tag 'Count' to each of these controls so the macro can identify them.

3
Write the VBA Macro

Press Alt + F11 to open the VBA Editor. Under the 'ThisDocument' module, write a macro that uses the SelectContentControlsByTag("Count") method.

4
Calculate the Total

In your script, iterate through the tagged controls and add up each control's Range.Words.Count to get the accurate word total for the designated parts.

5
Display the Result

Have the macro write the final sum directly into the 'Total' content control. Alternatively, store the result in a document variable and display it on the cover page using a DOCVARIABLE field.

Use Content Controls and VBA to Count Specific Sections
Macro Security Settings: You must ensure that macro execution is enabled in your software's Trust Center settings for the VBA script to run properly and update your counts.
Smart Word Processing

Easily Manage Word Counts in WPS Writer

WPS Office provides an intuitive Word Count tool and supports advanced document fields, making it incredibly easy to track the length of your essays, reports, or selected text sections without complex configurations.

  1. 1. Open your Document: Launch WPS Writer and open the .docx file you need to analyze.
  2. 2. Select Specific Sections: Highlight the text you want to count. Hold down the Ctrl key on your keyboard to select multiple non-adjacent paragraphs at once.
  3. 3. Check the Status Bar: Look at the bottom of the WPS Writer window to instantly view the combined word count for all your highlighted text.
  4. 4. Use Advanced Word Count: For a deeper breakdown, navigate to the Review tab and click 'Word Count' to see characters, lines, paragraphs, and choose whether to include footnotes.
Accurate real-time word count for selected text sections or the entire document.Fully compatible with Microsoft Word documents (.docx), content controls, and fields.Lightweight, fast, and completely free for standard document editing needs.
microsoft office alternative - wps office

Frequently Asked Questions

Does the standard word count include footnotes and endnotes?

By default, the status bar word count may not include footnotes and endnotes. You can include them by opening the Word Count dialog box from the Review tab and checking the box for 'Include textboxes, footnotes and endnotes'.

Can I update the DOCVARIABLE field automatically before printing?

Yes, you can ensure your fields are updated automatically. Go to File > Options > Display, and check the box that says 'Update fields before printing'.

Why does my VBA script throw an error when counting words?

This usually happens if macro security settings are restricting execution, or if the designated Content Control tags do not match exactly. Ensure your tag is spelled correctly and matches the exact casing (e.g., 'Count') used in your macro.

How do I count words in multiple non-adjacent sections without macros?

You can hold down the Ctrl key on Windows while highlighting different sections of your document. The status bar at the bottom will automatically calculate and display the combined word count of all the highlighted areas.