Question

Why does this word macro keep freezing?

By rahskir ·
I used the macro provided by the following:
http://www.techrepublic.com/article/macro-trick-how-to-highlight-multiple-search-strings-in-a-word-document/

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.ClearFormatting
Selection.Find.Replacement.ClearFormatting
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
Next
Next

End Sub
0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Software Forum
0 total posts (Page 1 of 1)  

Related Discussions

Related Forums