title: Efficient Word Count by Formatting Macro
body: <p>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).</p>
  
  <p>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?</p>
  
  <pre><code>    Dim highlightCount
      Dim boldCount
      Dim wordTotal
      boldCount = 0
      highlightCount = 0
  
      For Each w In ActiveDocument.Words
          If w.HighlightColorIndex &lt;&gt; 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 " &amp; wordTotal &amp; " words to be spread")
  End Sub
  </code></pre>