Wildcard Search/Replace

  • Thread starter Thread starter Tom K
  • Start date Start date
T

Tom K

I know I have done this once before, but now I can't figure it out
again.

Here's the example:

I want to do a find/replace on any line that has a 's in the
beginning;

ie,
'stom
'ssam

All I want to do is change all lines that fit this criteria (must
start with 's) to a red font. All other lines should be left as is.

Anyone have a clue? :)

Thanks
 
A macro would do the job

Sub MarkQuotedLines()
Dim orng As Range
With Selection
.HomeKey wdStory
Set orng = Selection.Range
orng.End = orng.End + 2
If orng.Text = "'s" Then
orng.Paragraphs(1).Range.Font.Color _
= wdColorRed
End If
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWildcards = True
While .Execute("^13's")
Set orng = Selection.Range
orng.Start = orng.Start + 1
orng.Paragraphs(1).Range.Font.Color _
= wdColorRed
Wend
End With
End With
End Sub

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top