title: Macro to remove highlighting from hyperlinks in Word
body: <p>I'm writing a macro to remove all highlight colors in a Word document except wdGray25 (whose HighlightColorIndex equals 15). The problem arises when macro runs into a hyperlink highlighted with wdGray25, whose hyperlink/field isn't highlighted when revealed by Alt+F9. In that case Do While .Execute loop goes into an infinite loop and never exits. </p>
  
  <p>How can I rewrite the code so that .Execute method wouldn't go into an infinite loop? I appreciate your help.</p>
  
  <pre><code>color_array = Array("2", "3", "4", "5", "6", "7", "9", "10", "11", "12", "13", "14")
  
  For Each color_number In color_array
  
  With Selection
  .HomeKey Unit:=wdStory
  With Selection.Find
    .Highlight = True
    .Text = ""
  
    Do While .Execute
     If Selection.Range.HighlightColorIndex = color_number Then
        Selection.Range.HighlightColorIndex = wdNoHighlight
        Selection.Collapse wdCollapseEnd
      End If
    Loop
  
  End With
  End With
  Next
  </code></pre>