Wildcard Search/Replace

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
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

You are welcome :)

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top