Why does this word macro keep freezing?

By rahskir ·
I used the macro provided by the following:

I ended up inputting 226 words in it. Now every time I use it, I get the spinning wheel and have to force-close word. Word restarts, the file recovers, and all my terms are highlighted perfectly. This is great, but I can't exactly share the macro with co-workers in this state.

Below is an abbreviated version of what I have I will use "(...)" to skip over the list of words:
Sub litglossaryterms()
Dim Word As range
Dim WordCollection(0 To 225) As String

WordCollection(0) = "Abstention"
WordCollection(1) = "Ad hoc arbitration"
WordCollection(225) = "Work Product Doctrine"

Options.DefaultHighlightColorIndex = wdYellow

Selection.Find.Replacement.Highlight = True

For Each Word In ActiveDocument.Words
For Each Words In WordCollection
With Selection.Find
.Text = Words
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

End Sub

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums