Word count for only section of document
Solution 1
Loosening the VBA restrictions, the macro found on wordribbon.tips.net can calculate the number of words per section, given that each section is followed by a section break:
Sub WordCount()
Dim NumSec As Integer
Dim S As Integer
Dim Summary As String
NumSec = ActiveDocument.Sections.Count
Summary = "Word Count" & vbCrLf
For S = 1 To NumSec
Summary = Summary & "Section " & S & ": " _
& ActiveDocument.Sections(S).Range.ComputeStatistics(wdStatisticWords) _
& vbCrLf
Next
Summary = Summary & "Document: " & _
ActiveDocument.Range.ComputeStatistics(wdStatisticWords)
MsgBox Summary
End Sub
Note that I replaced .Words.Count
with .ComputeStatistics(wdStatisticWords)
for a more accurate count (based on the information in this KB article).
The current macro will show an alert with the word count per section, but of course this information can be stored as text in the document as well.
Solution 2
Finding the word-count of a section of the document:
- Select the section of interest
- Position to the Review pane
- In the Proofing group, click on Word Count:
Solution 3
When you select the section, just look at the status bar. The word count is shown there.
Related videos on Youtube
Jonny Wright
Engineer for a global engineering company Like all things tech Automating my home is a WIP.
Updated on September 18, 2022Comments
-
Jonny Wright over 1 year
I know it is possible to add a word count field (
NUMCOUNT
) to a document to create a dynamic word count, but is it possible to limit the word count to only a section of the document?I need a solution which does not use Macros/VBA.
-
Admin over 8 yearsThere is no per-section Word count field. The only way I could imagine doing this without VBA etc. would be to have each section in a separate file with a { NUMWORDS }, update each of those fields and lock the result, then combine the sections. And that would probably require a macro to do it reliably...
-
Jonny Wright over 8 yearsConsidering how far the Office suite has developed it surprises me that some features are still quite basic.
-
Admin over 8 yearsYes, fields have seen very little development (except in the sense that there are now also content controls, but they are not treated equally across the various platforms). IMO it would not have taken much to have a "bookmark" parameter for the { NUMWORDS } field, for example - how many words 'covered' by bookmark "abc". I always had the impression that the Word dev. people thought VBA coding could and would replace all that stuff (which of course, it can't) but who knows?
-
Nick Stauner over 7 yearsFWIW, you can subtract a constant from NUMWORDS if the word count outside the section of interest isn't changing. E.g.,
{ = { NUMWORDS } - 8 }
. UseCtrl+F9
to produce braces, notShift+[
. -
JohnLBevan over 5 yearsHere's a hacky solution: superuser.com/a/188471/156700
-
Butanium over 2 yearsfound this : word.tips.net/T000519_Word_Count_for_a_Section.html but it doesn't work well : every \n are counted as words
-
-
Butanium over 2 yearsThis doesn't answer the question. The word count has to be in the document.
-
Butanium over 2 yearsThis doesn't answer the question. The op want to insert in the document a field where the word count of the current section is displayed
-
harrymc over 2 years@Butanium: In this case the answer would have been negative - this is not possible without VBA.
-
Butanium over 2 yearsOh sorry I'll repost the question with macro allowed. superuser.com/questions/1701062/…