3 Methods to Count the Number of Words for Sections in Your Word Document

In this article, there will be 3 methods for you to count the number of words for sections in your Word document.

It’s easy to get the total number of words of a document. But there is no function in Word to tell us the number of words of a section. And given to the fact that we prefer to put contents of the same topic in one section, such as organizing a chapter while writing a book, it’s necessary for us to come up with workarounds to get the section count. Count the Number of Words for Sections in Your Word Document  Following are 3 approaches which require you running a macro.

Method 1: Count the Number of Words for Current Section

  1. Firstly, place cursor inside a target section.
  2. Then you need to open VBA editor in Word. Click “Developer” and then the “Visual Basic” command. In case you can’t find “Developer” in the Ribbon, then press “Alt+ F11” instead.
  3. Next click “Normal” project in the left column.
  4. Then click “Insert” tab.
  5. On that drop-down menu, choose “Module”.Click "Normal"->Click "Insert"->Click "Module"
  6. Open new module by double click.
  7. Now in the open module, paste bellowing codes:
Sub CountWordsOfCurrentSection()
  MsgBox ("There are " & Selection.Sections(1).Range.ComputeStatistics(wdStatisticWords) _
         & " words in current section.")
End Sub
  1. Lastly, click “Run” or press “F5” to execute codes.Paste Codes ->Click "Run"

You will receive a message box, showing the total number of current section, such as below:Number of Words in Current Section

Method 2: Count the Number of Words for a Specific Section

Let’s say you have been working on a book and setting each chapter as an individual section. Then to know how many words you’ve written in a chapter, you can utilize this method.

  1. Follow above steps to install and run a macro.
  2. Just replace macro with this one:
Sub CountWordsOfSpecificSection()
  Dim strSecNum As String
  Dim objDoc As Document
 
  Application.ScreenUpdating = False
 
  Set objDoc = ActiveDocument
  strSecNum = InputBox("Enter a section number here:", "Enter Section Number") 
  MsgBox ("There are " & objDoc.Sections(strSecNum).Range.ComputeStatistics(wdStatisticWords) _
          & " words in section " & strSecNum & ".")
  Application.ScreenUpdating = True
End Sub
  1. And running it, there will be an input box. In the “Enter Section Number” box, input the section number and click “OK” to move on.Enter Section Number->Click "OK"

The result is shown on a message box.

Method 3: Count the Number of Words for All Sections in a Document

As the subtitle suggests, this way shall get you total number of words of each section in a document and list them on a message box.

  1. First of all, open target document.
  2. Still, you have to repeat steps in method 1 to install and run the macro.
  3. And this time, change with this macro:
Sub CountWordsOfEachSectionInDoc()
  Dim objDoc As Document
  Dim nNumberOfSection As Long
  Dim strText As String
 
  Application.ScreenUpdating = False
  Set objDoc = ActiveDocument
  nNumberOfSection = objDoc.Sections.Count
 
  For nNumberOfSection = 1 To nNumberOfSection
    strText = strText & "There are " & objDoc.Sections(nNumberOfSection) _
              .Range.ComputeStatistics(wdStatisticWords) & " words in section " & nNumberOfSection & "; " _
              & vbNewLine
  Next nNumberOfSection
 
  MsgBox strText
 
  Application.ScreenUpdating = True
End Sub

Here is the possible outcome:Word Count for Each Section in Document

Save Valuable Data

While dealing with all kinds of documents, you have to keep in mind the safety of them. Since you can never tell when the next data loss shall happen, it’s suggested to back up important files. Besides, it’s always good to obtain a tool that can recover doc, if any.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xls repair and pdf repair software products. For more information visit www.datanumen.com

One response to “3 Methods to Count the Number of Words for Sections in Your Word Document”

Leave a Reply

Your email address will not be published. Required fields are marked *