How to Count Words in Each Word Paragraph Using a VBA Macro
Question details
The user needs to calculate and display the individual word count for every paragraph in a long document to analyze paragraph length.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Reviewing a lengthy document where the writer needs to identify paragraphs that are either too short or excessively long for better pacing and readability.
- Observed behavior
- Standard word count tools only provide the total document word count or the count for a manual selection, requiring a macro to automate paragraph-by-paragraph statistics.
Ensure your document is saved as a Macro-Enabled Document (.docm) and that the Developer tab is enabled in your ribbon before writing or running VBA code.
Insert Word Count Directly Before Each Paragraph
Use a VBA macro to loop through the document and insert the calculated word count at the beginning of each paragraph for quick inline reviewing.
This method modifies your active document by adding a text string (e.g., '[15 Words]') before the first word of each paragraph. It utilizes the ComputeStatistics(wdStatisticWords) method to ensure accurate counts.
Press ALT + F11 on your keyboard to open the Microsoft Visual Basic for Applications window.
In the top menu, click 'Insert' and select 'Module' to create a blank workspace for your macro.
Write a script that loops through 'ActiveDocument.Paragraphs', calculates the count using 'ComputeStatistics(wdStatisticWords)', and inserts the result using 'Paragraph.Range.InsertBefore'.
Press F5 or click the 'Run' button. The macro will process the document and prepend the word count to each paragraph.

Export Paragraph Word Counts to a New Document
Run a macro that extracts the word count of each paragraph and lists them in a separate, newly generated document.
Easily Run Macros and Count Words with WPS Writer
WPS Writer offers excellent compatibility with VBA macros, allowing you to run custom scripts like paragraph word counters seamlessly. It provides a lightweight, highly compatible, and user-friendly alternative for advanced document editing.
- 1. Download and Install WPS Office: Get the latest version of WPS Office from the official website and install it on your computer.
- 2. Open Your Document: Launch WPS Writer and open the document you wish to analyze.
- 3. Access the Developer Tab: Navigate to the Developer tab on the ribbon and click on 'VBA Editor' to input your paragraph word count macro.
- 4. Run the Script: Execute the macro directly within WPS Writer to view the word count statistics for every paragraph.

Frequently Asked Questions
Can I count words in a specific paragraph without using a macro?
Yes. If you only need to check a few paragraphs, simply highlight the paragraph with your mouse. The status bar at the bottom of the Word window will display the word count specifically for your highlighted selection.
How do I remove the word counts inserted by the macro later?
If your macro inserted the counts as specific text (for example, '[15 Words]'), you can use the Find and Replace feature (Ctrl + H) with wildcards to locate that exact text pattern and replace it with nothing, effectively removing it.
Why is my VBA macro not running in my document?
Macros are often disabled by default for security reasons. You need to go to your Trust Center settings, enable macros, and ensure your file is saved as a Macro-Enabled Document (.docm).




