4 Ways to Exclude Numbers in Your Word Document from Word Count Statistics

In today’s article, we will present you 4 effectual ways to exclude numbers in your Word document from word count statistics.

Generally, Word counts all types of texts, be they words or numbers. But, now and then, we are likely to do a word count excluding certain elements, such as numbers. Therefore, we are delighted to show you 4 methods to meet such a requirement.Exclude Numbers in Your Word Document from Word Count Statistics

Before all, you must take a backup of target document and operate all methods bellow on your copy.

Method 1: Delete All Numbers

  1. Firstly, open copy file and click the drop-down button on “Find” under “Home” tab.
  2. Secondly, choose “Advanced Find” to open “Find and Replace” dialog box.Click "Home"->Click "Find"->Choose "Advanced Find"
  3. Next enter “^#” in “Find what” text box. If you can’t remember this string, put cursor at “Find what” text box and click “More” then click “Special” button.
  4. Then select “Any Digit”.
  5. Now click “Find In” and choose “Main Document”.
  6. You will find all numbers are in selection.Enter "^#" in "Find what" Text Box->Click "Find In"->Choose "Main Document"
  7. Press “Delete”.
  8. Once numbers are gone, you can notice Word consider some punctuation marks as words now. So you need to remove all punctuation marks as well. Open “Find and Replace” box again. This time input “[,.;:’”””/\!\*\?\\]” (without quotation marks) in “Find what” text box.
  9. And remember to check “Use wildcards” box.
  10. Repeat step 5 to find all punctuation marks.Enter String in "Find what" Text Box->Click "Find In" ->Choose "Main Document"
  11. Delete them.
  12. Lastly, click “Review” then “Word Count” to view total number of texts.Click "Review"->Click "Word Count"

Method 2: Format All Numbers as Hidden Texts

Word doesn’t include hidden texts in word count, so you can choose to set numbers in hidden formatting.

  1. First of all, repeat first 6 steps in method.
  2. Instead of deleting selected numbers, press “Ctrl+ D” to open “Font” box.
  3. Check the “Hidden” box and click “OK”.Check "Hidden" Box->Click "OK"
  4. Next repeat from step 8 to 9 to find all punctuation marks.
  5. Similarly, follow step 2 and 3 to format punctuation marks as hidden texts.
  6. Finally, check the total words.

Method 3: Run Word Macro

The following macro will do the above steps automatically and return you a message box, containing the total number of words excluding numbers.

  1. To begin with, press “Alt+ F11” in Word to open VBA editor.
  2. Next click “Normal’ in the left column.
  3. Then click “Insert” tab and choose “Module”.Click "Normal"->Click "Insert"->Click "Module"
  4. Double click on module to open it and paste the bellowing codes:
Sub ExcludeNumbersFromWordCount()
  Dim objDoc As Document
  Dim nWord As Integer
 
  Set objDoc = ActiveDocument
 
  With Selection
    .HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
      .Text = "^#"
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      .Execute
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
 
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
      .Text = "[,.;:’" & ChrW(8221) & ChrW(8221) & """/\!\*\?\\]"
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchAllWordForms = False
      .MatchSoundsLike = False
      .MatchWildcards = True
      .Execute
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
  End With
 
  nWord = objDoc.Range.ComputeStatistics(wdStatisticWords)
 
  MsgBox ("There are " & nWord & " words in this document.")
End Sub
  1. Click “Run”.Paste Codes->Click "Run"

You will receive a message box, telling you how many words there in your document, such as bellow:Result Box

Method 4: Exclude Numbers in Tables from Word Count

Here is a particular need to exclude numbers in tables from word count. The solution is to run a macro.

  1. Install and run a macro as stated above in method 3.
  2. Then replace that macro with this one:
Sub ExcludeNumbersInTablesFromWordCount()
  Dim objDoc As Document, objNewDoc As Document
  Dim nWord As Integer, nWordInNewDoc As Integer, nWordInNewDocWithoutNum As Integer, nNumber As Integer
  Dim objTable As Table
  Dim objRange As Range
  Dim objParagraph As Paragraph
 
  Set objDoc = ActiveDocument
  Set objNewDoc = Documents.Add
  nWord = objDoc.Range.ComputeStatistics(wdStatisticWords)
 
  For Each objTable In objDoc.Tables
    objTable.Range.Select
    Selection.Copy
 
    Set objRange = objNewDoc.Range
 
    objRange.Collapse Direction:=wdCollapseEnd
    objRange.PasteSpecial DataType:=wdPasteRTF
    objRange.Collapse Direction:=wdCollapseEnd
    objRange.Text = vbCr
  Next objTable
 
  objNewDoc.Activate
 
  For Each objParagraph In ActiveDocument.Paragraphs
    If objParagraph.Range.Style = "Caption" Then
      objParagraph.Range.Delete
    End If
  Next objParagraph
 
  nWordInNewDoc = objNewDoc.Range.ComputeStatistics(wdStatisticWords)
 
  With Selection
    .HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
      .Text = "^#"
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      .Execute
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
 
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
      .Text = "[,.;:’" & ChrW(8221) & ChrW(8221) & """/\!\*\?\\]"
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchAllWordForms = False
      .MatchSoundsLike = False
      .MatchWildcards = True
      .Execute
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
  End With
 
  nWordInNewDocWithoutNum = objNewDoc.Range.ComputeStatistics(wdStatisticWords)
  nNumber = nWordInNewDoc - nWordInNewDocWithoutNum
  objDoc.Activate
  MsgBox ("There are " & nWord - nNumber & " words in this document, excluding numbers in tables.")
End Sub

There will be a message box such as this:Word Count Excluding Numbers in Tables

Think ahead

Given to the fact that Word is not foolproof, you must take preventive measures before everything is too late. The most useful way is to back up your documents and back up them as possible as you can. It might take just minutes to back up a document but hours even days to recover a corrupt docx. So think ahead to save you both time and money.

Author Introduction:

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

Leave a Reply

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