Search and replace a whole paragraph!

  • Thread starter Thread starter michaelharringt
  • Start date Start date
M

michaelharringt

SEARCH AND REPLACE A WHOLE PARAGRAPH

I would like to search for a word in a document e.g [p1] and replace
it with a whole paragraph or more but the replace box is limited to a
small number of characters

Is there another way I can do this?

Many thanks

Michael
 
Copy the paragraph to the clipboard then replace [p1] with ^c

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
Here's what I would suggest.

First, create an AutoText entry containing the paragraph of text that
you want to use as a replacement. To create the entry, type the text in
a document, then select it, then press Alt+F3 and type in the name you
want to use for the AutoText entry. Let's say the name you choose is
test.

Next, create a macro that will search for the word you want to replace,
which in this case is world, and replace it with the autotext entry,
named test. The below macro does the job:

Application.ScreenUpdating = False
With Selection.Find
.ClearFormatting
.Text = "world"
.Forward = True
.Wrap = wdFindContinue

Do While .Execute
NormalTemplate.AutoTextEntries("test").Insert Where:=Selection.Range,
RichText:=True
Loop
End With

Larry
 
Back
Top