In this article, we would like to offer you 2 quick ways to count the number of highlighted words in your Word document.
From time to time, we would highlight texts in different topics with different colors. In case you want to count the total number of highlighted words, you must understand that there is no direct way in Word to do this task. But as workarounds, you can choose to pick either one of the following methods in different cases.
Method 1: Count All Highlighted Words in Different Colors
- First of all, press “Alt+ F11” to open the VBA editor in Word.
- Next click “Normal” on the left column.
- Then click “Insert” on the menu bar.
- On the drop-down menu, choose “Module”.
- And double click on the new module to open it.
- Paste the following macro there:
Sub CountAllWordsInHighlight() Dim objWord As Range Dim nHighlightedWords As Long Dim objDoc As Document Application.ScreenUpdating = False Set objDoc = ActiveDocument With Selection .HomeKey Unit:=wdStory With Selection.Find .Highlight = True Do While .Execute nHighlightedWords = nHighlightedWords + Selection.Range.ComputeStatistics(wdStatisticWords) Selection.Collapse wdCollapseEnd Loop End With End With MsgBox ("The total number of highlighted words is " & nHighlightedWords & " .") Application.ScreenUpdating = True Set objDoc = Nothing End Sub
- Last but not the least, click “Run” button or hit “F5” to execute the codes.
There will be a message box showing up, such as below:
Method 2: Count All Highlighted Words in a Specific Color
As we mentioned above, there can be several highlight colors applied to your Word document. Therefore, it’s kind of difficult to get the word count of highlighted words in a particular color. Fortunately, we could always rely on macro to do some customized task.
- First of all, repeat steps in method 1 to install and run a macro.
- Then replace with this macro:
Sub CountWordsInASpecificHighlightColor() Dim objDoc As Document Dim objWord As Object Dim nHighlightedWords As Long Dim strHighlightColor As String Application.ScreenUpdating = False Set objDoc = ActiveDocument nHighlightedWords = 0 strHighlightColor = InputBox("Choose a Highlight colour (enter the value):" & vbNewLine & _ vbTab & "Auto" & vbTab & vbTab & "0" & vbNewLine & _ vbTab & "Black" & vbTab & vbTab & "1" & vbNewLine & _ vbTab & "Blue" & vbTab & vbTab & "2" & vbNewLine & _ vbTab & "BrightGreen" & vbTab & "4" & vbNewLine & _ vbTab & "DarkBlue" & vbTab & vbTab & "9" & vbNewLine & _ vbTab & "DarkRed" & vbTab & vbTab & "13" & vbNewLine & _ vbTab & "DarkYellow" & vbTab & "14" & vbNewLine & _ vbTab & "Gray25" & vbTab & vbTab & "16" & vbNewLine & _ vbTab & "Gray50" & vbTab & vbTab & "15" & vbNewLine & _ vbTab & "Green" & vbTab & vbTab & "11" & vbNewLine & _ vbTab & "Pink" & vbTab & vbTab & "5" & vbNewLine & _ vbTab & "Red" & vbTab & vbTab & "6" & vbNewLine & _ vbTab & "Teal" & vbTab & vbTab & "10" & vbNewLine & _ vbTab & "Turquoise" & vbTab & "3" & vbNewLine & _ vbTab & "Violet" & vbTab & vbTab & "12" & vbNewLine & _ vbTab & "White" & vbTab & vbTab & "8" & vbNewLine & _ vbTab & "Yellow" & vbTab & vbTab & "7", "Pick Highlight Color") For Each objWord In objDoc.Words If objWord.HighlightColorIndex = strHighlightColor Then nHighlightedWords = nHighlightedWords + 1 End If Next objWord MsgBox ("The number of highlighted words is " & nHighlightedWords & " .") Application.ScreenUpdating = True Set objDoc = Nothing End Sub
- Next in “Pick Highlight Color” box, enter a color value and click “OK”. For example, here we enter “7”, representing the yellow color.
- Now here is the outcome:
Smartly Solve the Document Corruption Issue
Now and then, you can encounter with Word damage. The worst of it is that it can lead to broken documents. While you can utilize the built-in feature in Word to recover your document, you can also resort to another clever choice that is to get a repairing tool to retrieve your data in the least time.
Author Introduction:
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupted xls and pdf repair software products. For more information visit www.datanumen.com
1
This class has helped me develop rhetorical knowledge by analyzing and composing multiple forms of writing to understand how genre conventions shape readers’ and writers’ practices and purposes. This means that I have been able to analyze different types of writing in order to understand how a genre affects how an author writes, and how the reader reads. One assignment that comes to mind that helped me achieve this outcome was our advertisement analysis assignments. In class, we spent time looking at different advertisements, and how they appealed to certain audiences. We all had to bring an advertisement to class, and analyze it ourselves, pointing out what techniques the ads were using, if they were effective or not, and who were they targeting. This assignment helps develop rhetoric as it allowed me to understand how the category of advertisement writing can differ from not only other genres, but other ads as well Two more ways I was able to develop my critical thinking, reading, and information literacy skills was by using outside materials in their own writing through techniques such as interpretation, synthesis, response, critique, and design/redesign, and incorporating outside materials through quotations, paraphrase, and summary. By completing the image analysis essay, I was able to meet the outcome about using outside materials in your own writing. I used two advertisements in the essay, and analyzed how they were done, and who they targeted, in order to compare and contrast them at the end. I appropriately commented on their effectiveness, and how they could have improved. Speaking of using outside materials, my goal
I have a massive master draft in Microsoft Word and eventually want to separate it into several books, but in the meantime I don’t want to lose the master draft which I continue to work on. This fix above has worked brilliantly! Even better that we can highlight in different colours and extract word counts accordingly. Thank you so much.