P
prs16001
I'm trying to run a macro over a long document but only want to do a find
within a specific range, an redefine the range as until I reach the end of
the document. I was able to specify a specific range using the code from an
earlier post (1/24/06), but I cannot do a find once that range is defind. I
used the following to define the range
Dim oRngStart As Range
Dim oRngEnd As Range
Dim oRngDefined As Range
With Selection
..HomeKey Unit:=wdStory
With .Find
..ClearFormatting
..Text = "xxxxxx"
..Execute
Set oRngStart = Selection.Range
Selection.MoveRight
..Text = "yyyyy"
..Execute
Set oRngEnd = Selection.Range
End With
End With
Set oRngDefined = ActiveDocument.Range(Start:=oRngStart.End,
End:=oRngEnd.Start)
I then use
with oRngDefined.find
.Text="texttofind"
.Execute
End with
But the find oeration moved beyond the "oRngDefined" range when searching
for "texttofind".
within a specific range, an redefine the range as until I reach the end of
the document. I was able to specify a specific range using the code from an
earlier post (1/24/06), but I cannot do a find once that range is defind. I
used the following to define the range
Dim oRngStart As Range
Dim oRngEnd As Range
Dim oRngDefined As Range
With Selection
..HomeKey Unit:=wdStory
With .Find
..ClearFormatting
..Text = "xxxxxx"
..Execute
Set oRngStart = Selection.Range
Selection.MoveRight
..Text = "yyyyy"
..Execute
Set oRngEnd = Selection.Range
End With
End With
Set oRngDefined = ActiveDocument.Range(Start:=oRngStart.End,
End:=oRngEnd.Start)
I then use
with oRngDefined.find
.Text="texttofind"
.Execute
End with
But the find oeration moved beyond the "oRngDefined" range when searching
for "texttofind".