logo
search
VBA & Macro Problems

How to Use VBA for Word Count Excluding Tables and Text Boxes

Maira MehtabMaira Mehtab Sep 22, 2026 869 views

Question details

The user requires a VBA macro to perform a precise word count for a PhD thesis that excludes tables, text boxes, diagrams, headers, footers, footnotes, endnotes, and other specific document elements.

Product
Word Processing
Device & OS
not provided
Scenario
Writing an academic document or PhD thesis that enforces strict word count rules and requires excluding certain structural objects from the total count.
Observed behavior
Built-in word statistics do not automatically isolate and exclude every object type, such as table content, the table of contents, and bibliographies.
Before you start

Ensure you have the Developer tab enabled in your word processor to insert and run VBA macros, and clearly define your exact word counting rules before relying on the script.

Solution 1

Understand Built-in Word Count Exclusions

Learn which elements are automatically excluded by default word counting fields before utilizing advanced scripts.

The built-in NUMWORDS field already excludes text inside text boxes, diagrams, headers, footers, footnotes, and endnotes automatically. However, standard calculations will still include text located inside tables, the table of contents, the index, and the bibliography unless these tables are placed inside a text box.

1
Check default statistics

Click the word count indicator on your bottom status bar to view the default statistics and uncheck 'Include textboxes, footnotes and endnotes' if available.

2
Identify remaining elements

Manually identify if your document contains extensive tables, indexes, or bibliographies, as these will artificially inflate the default word count.

Professional Word Processing

Accurately Track Your Word Count with WPS Writer

WPS Writer offers an intuitive interface with comprehensive word count statistics built right into the status bar, alongside excellent support for running advanced VBA macros to meet strict academic counting rules.

  1. 1. Open your document: Launch WPS Writer and open your thesis or target document.
  2. 2. Access Word Count: Click on the 'Review' tab at the top and select 'Word Count' to view detailed document statistics.
  3. 3. Exclude extra elements: In the pop-up dialog box, simply uncheck 'Include textboxes, footnotes and endnotes' to instantly exclude them from your total.
  4. 4. Run VBA for tables: For advanced exclusions like tables and bibliographies, navigate to the 'Developer' tab, click 'Macros', and run custom scripts effortlessly.
Fully compatible with Microsoft Word document formats (.docx)Built-in detailed word count statistics for characters, lines, and pagesSupports advanced VBA macros for custom counting requirementsLightweight, fast, and free to use
microsoft office alternative - wps office

Frequently Asked Questions

Does the default word count include text boxes and diagrams?

By default, the built-in word count usually excludes text boxes, diagrams, headers, footers, and footnotes. However, it still includes content within standard tables and auto-generated fields like bibliographies.

How do I run a VBA macro in my word processor?

You can run a macro by pressing Alt + F11 to open the Visual Basic Editor, inserting a new module from the 'Insert' menu, pasting your code, and then pressing F5 to execute the script.

Can I exclude tables from my word count without using VBA?

To completely exclude tables without using a macro, you would need to manually subtract the word count of each table from the total, or temporarily copy all standard text (ignoring tables) into a new blank document to check its count.