how to replace text in specific area of word document

T

turneg02

i want to be able to replace all values of wordA with wordB but only within a
certain area of the word document. how is this done?
 
G

Graham Mayor

Select the text before running the replace tool and don't replace in the
rest of the document when prompted.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
H

Helmut Weber

Hi,

like this:

Sub test8888()
Dim rPrg As Range
Set rPrg = ActiveDocument.Paragraphs(2).Range ' e.g.
ResetSearch
With rPrg.Find
.Text = "o"
.Replacement.Text = "x"
.Wrap = wdFindStop
.Execute Replace:=wdReplaceAll
End With
ResetSearch
End Sub

Public Sub ResetSearch()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
End Sub

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

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