locked
Word counts RRS feed

  • Question

  • Hello.

    I see a word count on my document as 5871 on the bottom left as the screen between page numbering and language.

    However I have also used Quickparts, Field then Numwords but the number that comes up is 5303.  Why the difference?  I am including footnotes etc.

    I need to hit 5,000 words and so need to know how many to cut!

    Thanks

    Saturday, January 2, 2016 11:02 AM

Answers

  • The difference is due to the count on the status bar including words in footnotes, endnotes & textboxes (this is a user-configurable setting), none of which the NUMWORDS field includes.

    The following macro generates a comprehensive set of word counts for a document. If you only want the word count for a selected range, change ‘ActiveDocument’ to ‘Selection’. Do note that, with the latter, the word counts for footnotes & end notes will relate to those anchored in the selected range, regardless of where they’re physically located.

    Sub CountWords()
    Application.ScreenUpdating = False
    Dim oTbl As Table, lTbl As Long, Sctn As Section
    Dim oHdFt As HeaderFooter, lHdr As Long, lFtr As Long
    Dim oEnt As Endnote, lEnt As Long
    Dim oFnt As Footnote, lFnt As Long
    Dim oShp As Shape, lShp As Long
    Dim oPara As Paragraph, lCpt As Long
    With ActiveDocument
      For Each oTbl In .Tables
        lTbl = lTbl + oTbl.Range.ComputeStatistics(wdStatisticWords)
      Next
      For Each oEnt In .Endnotes
        lEnt = lEnt + oEnt.Range.ComputeStatistics(wdStatisticWords)
      Next
      For Each oFnt In .Footnotes
        lFnt = lFnt + oFnt.Range.ComputeStatistics(wdStatisticWords)
      Next
      For Each Sctn In .Sections
        For Each oHdFt In Sctn.Headers
          If Not oHdFt.LinkToPrevious Then _
            lHdr = lHdr + oHdFt.Range.ComputeStatistics(wdStatisticWords)
        Next
        For Each oHdFt In Sctn.Footers
          If Not oHdFt.LinkToPrevious Then _
            lFtr = lFtr + oHdFt.Range.ComputeStatistics(wdStatisticWords)
        Next
      Next
      For Each oShp In .Endnotes
        If Not oShp.TextFrame Is Nothing Then _
          lShp = lShp + oShp.TextFrame.TextRange.ComputeStatistics(wdStatisticWords)
      Next
      For Each oPara In .Paragraphs
        If oPara.Style = "Caption" Then _
          lCpt = lCpt + oPara.Range.ComputeStatistics(wdStatisticWords)
      Next
      MsgBox "Word Count Statistics:" & vbCr & _
        "Tables - " & vbTab & vbTab & lTbl & vbCr & _
        "EndNotes - " & vbTab & lEnt & vbCr & _
        "Footnotes - " & vbTab & lFnt & vbCr & _
        "Headers - " & vbTab & vbTab & lHdr & vbCr & _
        "Footers - " & vbTab & vbTab & lFtr & vbCr & _
        "Shapes - " & vbTab & vbTab & lShp & vbCr & _
        "Captions - " & vbTab & lCpt & vbCr & _
        "Other - " & vbTab & vbTab & .Range.ComputeStatistics(wdStatisticWords) - lTbl - lCpt
    End With
    Application.ScreenUpdating = True
    End Sub


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Monday, January 4, 2016 7:54 AM