G
Greg
Regulars here will acknowledge that I am a novice. Yesterday an OP asked how
to automatically format repetive words in a different font style. I don't
know of anything other than the spell checker repeated word marker that would
automatically flag repeated words as the user typed, but I started playing
with a macro that would evaluate a bit of completed text for repetitive words
and mark as appropriate. My cobbled attempt follows. Basically the macro
simply looks at a word, compares it to the last word, and changes the font
attributes if the two match. Problems encountered was with the first word
since there isn't a previous word which I worked around with the error
handler, second problem was with empty paragraphs picking up the formating
which I got around by skipping them.
I would appreciate any comments on this method or pointers to a more
efficient method. Thanks
Sub Test()
Dim i As Long
Dim aWord As Range
i = 0
For Each aWord In ActiveDocument.Words
i = i + 1
On Error GoTo Skip
If aWord = Chr$(13) Then GoTo Skip
If aWord = ActiveDocument.Words(i - 1) Then
With aWord.Font
.Bold = True
.Color = wdColorBlue
End With
End If
Skip:
Next aWord
End Sub
to automatically format repetive words in a different font style. I don't
know of anything other than the spell checker repeated word marker that would
automatically flag repeated words as the user typed, but I started playing
with a macro that would evaluate a bit of completed text for repetitive words
and mark as appropriate. My cobbled attempt follows. Basically the macro
simply looks at a word, compares it to the last word, and changes the font
attributes if the two match. Problems encountered was with the first word
since there isn't a previous word which I worked around with the error
handler, second problem was with empty paragraphs picking up the formating
which I got around by skipping them.
I would appreciate any comments on this method or pointers to a more
efficient method. Thanks
Sub Test()
Dim i As Long
Dim aWord As Range
i = 0
For Each aWord In ActiveDocument.Words
i = i + 1
On Error GoTo Skip
If aWord = Chr$(13) Then GoTo Skip
If aWord = ActiveDocument.Words(i - 1) Then
With aWord.Font
.Bold = True
.Color = wdColorBlue
End With
End If
Skip:
Next aWord
End Sub