View Single Post
 
Old 11-18-2010, 12:20 AM
anil3b2 anil3b2 is offline Windows XP Office 2003
Novice
 
Join Date: May 2010
Posts: 7
anil3b2 is on a distinguished road
Default Find and Replace within range

Hi All,

I have selected one para and i need to find and replace something like below but it replaces in all places in the document rather than within that range/selection. In the below code instead "myrange" if i use "Selection." then also i get the same result. Please help me.

With myrange.Find
.text = "<([0-9]{1,5})>([-|^=])<([0-9]{1,5})>"
.Replacement.text = "<Pages>^&</Pages>"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWildcards = True
End With
Do While myrange.Find.Execute
msgbox(selection.text)
Loop
Reply With Quote