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.
Before all, you must take a backup of target document and operate all methods bellow on your copy.
Method 1: Delete All Numbers
- Firstly, open copy file and click the drop-down button on “Find” under “Home” tab.
- Secondly, choose “Advanced Find” to open “Find and Replace” dialog box.
- 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.
- Then select “Any Digit”.
- Now click “Find In” and choose “Main Document”.
- You will find all numbers are in selection.
- Press “Delete”.
- 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.
- And remember to check “Use wildcards” box.
- Repeat step 5 to find all punctuation marks.
- Delete them.
- Lastly, click “Review” then “Word Count” to view total number of texts.
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.
- First of all, repeat first 6 steps in method.
- Instead of deleting selected numbers, press “Ctrl+ D” to open “Font” box.
- Check the “Hidden” box and click “OK”.
- Next repeat from step 8 to 9 to find all punctuation marks.
- Similarly, follow step 2 and 3 to format punctuation marks as hidden texts.
- 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.
- To begin with, press “Alt+ F11” in Word to open VBA editor.
- Next click “Normal’ in the left column.
- Then click “Insert” tab and choose “Module”.
- 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
- Click “Run”.
You will receive a message box, telling you how many words there in your document, such as bellow:
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.
- Install and run a macro as stated above in method 3.
- 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:
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









