I have a word macro that counts all text in a document that is either highlighted or Un-underlined bold. The macro works fine - although the counts are slightly higher than what the "Find" feature returns on some documents (if anyone knows why I'd be excited to figure it out).
The issue with the macro is that it is remarkably inefficient and lags my computer for a non-trivial amount of time when running on documents of around 50 pages in length. Does anyone see a more efficient way to write a macro of similar functionality?
Dim highlightCount
Dim boldCount
Dim wordTotal
boldCount = 0
highlightCount = 0
For Each w In ActiveDocument.Words
If w.HighlightColorIndex <> wdNoHighlight Then
highlightCount = highlightCount + 1
End If
If w.Font.Bold = True Then
If w.HighlightColorIndex = wdNoHighlight Then
If w.Font.Underline = False Then
boldCount = boldCount + 1
End If
End If
End If
Next
wordTotal = highlightCount + boldCount
MsgBox ("There are " & wordTotal & " words to be spread")
End Sub