Word count for only section of document

13,060

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:

enter image description here

Solution 3

When you select the section, just look at the status bar. The word count is shown there.

Word count shown on the status bar

Share:
13,060

Related videos on Youtube

Jonny Wright
Author by

Jonny Wright

Engineer for a global engineering company Like all things tech Automating my home is a WIP.

Updated on September 18, 2022

Comments

  • Jonny Wright
    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
      Admin over 8 years
      There 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
      Jonny Wright over 8 years
      Considering how far the Office suite has developed it surprises me that some features are still quite basic.
    • Admin
      Admin over 8 years
      Yes, 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
      Nick Stauner over 7 years
      FWIW, you can subtract a constant from NUMWORDS if the word count outside the section of interest isn't changing. E.g., { = { NUMWORDS } - 8 }. Use Ctrl+F9 to produce braces, not Shift+[.
    • JohnLBevan
      JohnLBevan over 5 years
      Here's a hacky solution: superuser.com/a/188471/156700
    • Butanium
      Butanium over 2 years
      found this : word.tips.net/T000519_Word_Count_for_a_Section.html but it doesn't work well : every \n are counted as words
  • Butanium
    Butanium over 2 years
    This doesn't answer the question. The word count has to be in the document.
  • Butanium
    Butanium over 2 years
    This 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
    harrymc over 2 years
    @Butanium: In this case the answer would have been negative - this is not possible without VBA.
  • Butanium
    Butanium over 2 years
    Oh sorry I'll repost the question with macro allowed. superuser.com/questions/1701062/…