K
Kokomojo
Hi, I'm wondering if someone would be kind enough to help me. I'm working
with a script and want to highlight different character names and their
dialogue. I can highlight the character names easily with Find and Replace.
But their subsequent dialogue, in a new paragraph under their character
names, is proving more difficult. I've created a macro that will do this,
but when it reaches the end of the script, it asks me if I want to continue
searching at the top of the document. If I say yes, it loops infinitely; if
I say no, it keeps asking again and again, another loop. Here's my code,
below. Any help is appreciated. Thanks.
Sub HighlightEllie()
'
' HighlightEllie Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = True
Options.DefaultHighlightColorIndex = wdYellow
With Selection.Find
.Text = "ELLIE^p"
.Replacement.Text = "ELLIE^p"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find
.Text = "ELLIE^p"
.Replacement.Text = "ELLIE^p"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
End With
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Do While True
With Selection.Find
.Text = "ELLIE^p"
.Forward = True
.Wrap = wdFindAsk
.MatchCase = True
End With
Selection.Find.Execute
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
Options.DefaultHighlightColorIndex = wdYellow
Selection.Range.HighlightColorIndex = wdYellow
Selection.HomeKey Unit:=wdLine
Loop
End Sub
with a script and want to highlight different character names and their
dialogue. I can highlight the character names easily with Find and Replace.
But their subsequent dialogue, in a new paragraph under their character
names, is proving more difficult. I've created a macro that will do this,
but when it reaches the end of the script, it asks me if I want to continue
searching at the top of the document. If I say yes, it loops infinitely; if
I say no, it keeps asking again and again, another loop. Here's my code,
below. Any help is appreciated. Thanks.
Sub HighlightEllie()
'
' HighlightEllie Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = True
Options.DefaultHighlightColorIndex = wdYellow
With Selection.Find
.Text = "ELLIE^p"
.Replacement.Text = "ELLIE^p"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
With Selection.Find
.Text = "ELLIE^p"
.Replacement.Text = "ELLIE^p"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
End With
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Do While True
With Selection.Find
.Text = "ELLIE^p"
.Forward = True
.Wrap = wdFindAsk
.MatchCase = True
End With
Selection.Find.Execute
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
Options.DefaultHighlightColorIndex = wdYellow
Selection.Range.HighlightColorIndex = wdYellow
Selection.HomeKey Unit:=wdLine
Loop
End Sub