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.
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.
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.
It'd be really nice to have a live display of the per-section word count. It's a pain to have to select the whole section every time you want to add it up. I found a workaround:
You'll need to take care if you're adding words at the start or end, and make sure the new content is contained in the selected text in the second window.
Not strictly answering the question (since the word count is not contained in the document) but it might help someone.
Finding the word-count of a section of the document: