A couple of points.
Firstly are you sure that the first two Finds are successful (as the code
doesn't check)?
Secondly, if the Find Range (oRngDefined) happens to equal the Find Text
exactly (texttofind), Find will not consider that to be part of the Range to
search (assuming it to have been the result of the previous Find,
presumably) and will start searching forward from the end of the Find Range.
--
Enjoy,
Tony
> 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
[quoted text clipped - 33 lines]
> But the find oeration moved beyond the "oRngDefined" range when searching
> for "texttofind".
prs16001 - 18 Apr 2006 15:43 GMT
Tony,
The first 2 finds were successfull. I checked this by adding
"select.oRngDefine" after defining it and the range I wanted was highlighted.
I'm at the early stages of creating this macro and will need to do a check
to see if the finds are successfull.
The range of oRngDefined is very large (4 pages, 852 words, 5294
characters), and I want to find text within that, so the third find (e.g.
.text="texttofind") is a subset of the defined range and is contained within
that range. The overall document is large (200X the above defined range) and
the start and end markers I'm interested in are repeated multiple times with
different information contained within that range. I want to find the
information between those ranges.
thanks
> A couple of points.
>
[quoted text clipped - 49 lines]
> > But the find oeration moved beyond the "oRngDefined" range when searching
> > for "texttofind".
Helmut Weber - 18 Apr 2006 16:31 GMT
Hi,
how about this one:
Sub Macro6000()
Dim rDcm As Range
Dim rTmp As Range
Set rDcm = ActiveDocument.Range
Set rTmp = Selection.Range
With rDcm.Find
.Text = "Landmark1*Landmark2"
.MatchWildcards = True
If .Execute Then
rTmp.SetRange Start:=rDcm.Start, End:=rDcm.End
With rTmp.Find
.Text = "quick"
.Replacement.Text = "quick"
.Replacement.Font.Color = wdColorRed
.Wrap = wdFindStop
.Execute Replace:=wdReplaceAll
End With
End If
End With
End Sub
Need further clarification, ask again.

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Greg Maxey - 18 Apr 2006 17:23 GMT
Helmut,
or...
Sub Macro6000()
Dim oRngMajor As Range
Dim rRngMinor As Range
Set oRngMajor = ActiveDocument.Range
With oRngMajor.Find
.Text = "xxxxx*yyyyy"
.MatchWildcards = True
If .Execute Then
Set oRngMinor = oRngMajor.Duplicate
With oRngMinor.Find
.Text = "test"
.Replacement.Font.Color = wdColorRed
.Wrap = wdFindStop
.Execute Replace:=wdReplaceAll
End With
End If
End With
End Sub
Helmut Weber - 18 Apr 2006 17:35 GMT
Hi Submariner,
yes,
it's only that I never really understood
that duplicating of a range.
Maybe, I'll get it now.

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Greg Maxey - 18 Apr 2006 17:50 GMT
Helmut,
I'm the same way, but I always try it and if it works great, if not I
just stumble on in the dark.
prs16001 - 18 Apr 2006 19:43 GMT
Thanks gentlemen, that is working for me now. I did have some trouble
initially since the first search I was using special characters (^w) and the
text contained the characters "[" and "]". But after some fumbling, I was
able to get it working using the wildcard.
prs16001 - 18 Apr 2006 20:35 GMT
I now have the find working but not the way I need. I now have the subset of
text selected with your help. On the next find operation searching only
through the defined range, I want to select or extract text which is
different that the text in the find operation. As an example of the definded
range,
xxxxxx
anything
anything
texttofind this is what I really want
anything
anything
yyyyyyy
I want to do the find operation several times within the defined range. In
most circumstances,the text that I want is to the right of the text used the
find operation. I thought I could use
Selection.MoveRight unit:=wdCharacter, Count:=2
Selection.MoveRight unit:=wdSentence, Count:=1, Extend:=wdExtend
textiwant = Selection.Text
to select the text but that isn't working. I need to run the find operation
several times, each time looking for a different text string and selecting
the text to the right.
Helmut Weber - 19 Apr 2006 09:44 GMT
Hi,
working with ranges is sometimes tricky indeed.
When searching the activedocument.range, not like rDcm here,
but in numerous other examples to be found in this group,
rDcm shrinks to the find spot and expands again to the rest of the doc.
Sometimes one has to take care of all the shrinking and expanding oneself.
But it's worth while getting used to it.
Stay away from the selection.
One more example, without being able to discuss all aspects
and all possible complications.
Dim p1 As Long
Dim rDcm As Range
Dim rTmp As Range
Set rDcm = ActiveDocument.Range
Set rTmp = Selection.Range
With rDcm.Find
.Text = "Landmark1*Landmark2"
.MatchWildcards = True
If .Execute Then
Set rTmp = rDcm.Duplicate
p1 = rTmp.End
With rTmp.Find
.Text = "quer"
While .Execute
MsgBox rTmp.Characters.Last.Next.Sentences(1)
rTmp.Collapse direction:=wdCollapseEnd
rTmp.End = p1
Wend
End With
End If
End With
End Sub

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