PDA

View Full Version : Solved: Find/Replace with Return Character



Anne Troy
02-17-2005, 06:07 AM
I have a macro that inserts the ? character:

Selection.InsertSymbol CharacterNumber:=182, Unicode:=True, Bias:=0

What I need is to find the real paragraph return, and replace it with this character AND a paragraph return. Here's the code I'd use to find a real paragraph return and replace it with an "X" and the real paragraph return:

Sub Macro3()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = "X^p"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

I am working on a book with code in it. I want to display to the reader where they must enter paragraph returns. My alternative is to type in so many underscores to make the code fit all within this 4-inch wide page.
:banghead:

Help me, help me!

TonyJollans
02-17-2005, 07:04 AM
Hi Anne,

Just change:
.Replacement.Text = "X^p"
To
.Replacement.Text = Chr(182) & "^p"

Anne Troy
02-17-2005, 07:13 AM
Yay!!
Thanks, Tony!!

Anne Troy
03-06-2005, 03:22 PM
You know, Tony.... about half the time I run this dang macro, it replaces all of them--not just the selection. Is that bizarre or what? I just undo and do it again and again until it just does the selection. I don't get it. Word 2000.

TonyJollans
03-06-2005, 04:55 PM
Try changing
.Wrap = wdFindContinue
to
.Wrap = wdFindStop

Anne Troy
03-06-2005, 05:23 PM
k. thanks!