Count Words Including Footnotes and Endnotes With a Word VBA Macro
Question details
Update a Word macro so its word total includes the main document, footnotes, and endnotes.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A user wants a VBA macro to report a document's word count with its footnotes and endnotes included.
- Observed behavior
- The existing macro counts only the main document story, so its total omits words in footnotes and endnotes.
Open the document in a version of Microsoft Word that supports VBA macros. Make sure the Developer tab is available, and allow macros only if you trust the document and its code.
Count the main document, footnote, and endnote story ranges
Use this macro to add the word counts from all three relevant Word story types in the active document.
Word stores the main document, footnotes, and endnotes in separate story ranges. This macro counts those story types and follows any linked ranges; it does not count headers, footers, or text boxes.
In Word, select Developer > Visual Basic. If Developer is not visible, enable it through Word's ribbon customization settings.
In the VBA editor, select Insert > Module and paste this code: Sub CountWordsWithNotes() Dim story As Range Dim part As Range Dim total As Long For Each story In ActiveDocument.StoryRanges Select Case story.StoryType Case wdMainTextStory, wdFootnotesStory, wdEndnotesStory Set part = story Do While Not part Is Nothing total = total + part.ComputeStatistics(wdStatisticWords) Set part = part.NextStoryRange Loop End Select Next story MsgBox "Words including footnotes and endnotes: " & total End Sub
Return to Word, select Developer > Macros, choose CountWordsWithNotes, and select Run. The total appears in a message box.
Select Review > Word Count and enable the option to include footnotes and endnotes. Compare the result with the macro total, keeping in mind that Word's option may also include text boxes, which this macro excludes.

Review Word documents with WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface and support for Word formats, making it easy to move documents between suites. The Word VBA macro fix must be performed in Microsoft Word; check macro compatibility before migrating automated workflows.

Frequently Asked Questions
Why does my Word macro miss footnote and endnote words?
Footnotes and endnotes are stored in separate Word story ranges. A macro that counts only wdMainTextStory does not include wdFootnotesStory or wdEndnotesStory.
How can I check the total manually in Word?
Open Review > Word Count and select the option to include footnotes and endnotes. Depending on the Word version, that option may also include text boxes.
Will the macro work if a document has no footnotes or endnotes?
Yes. The macro loops through the story ranges present in the active document, so absent footnote or endnote stories add nothing to the total.
Does this macro count words in multiple Word files?
No. It uses ActiveDocument. To process multiple files, adapt the code to open each file and calculate its story-range total separately.




