The following code tells me if the searched text exists:
Dim FoundText as Boolean
With ActiveDocument.Range.Find
FoundText = .Execute("The text I am searching for")
End With
How can I extract the exact paragraph object where this text is found?
I do not wish to manipulate the text, merely goto the location as if this
were a bookmark.
Dave Lett - 15 Feb 2005 17:39 GMT
Hi Jamie,
The easiest way to extract the text might be to simply select it using the
selection object instead of the Range object, as in the following:
Dim FoundText As Boolean
Dim sExtractText as String
With Selection.Find
FoundText = .Execute("The text I am searching for")
End With
sExtractText = Selection.Text
HTH,
Dave
> The following code tells me if the searched text exists:
>
[quoted text clipped - 8 lines]
> I do not wish to manipulate the text, merely goto the location as if this
> were a bookmark.
Jonathan West - 15 Feb 2005 17:47 GMT
> The following code tells me if the searched text exists:
>
[quoted text clipped - 8 lines]
> I do not wish to manipulate the text, merely goto the location as if this
> were a bookmark.
Do this
ActiveDocument.Range.Select
Selection.Find.Execute "The text I am searching for"

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Jamie Carper - 15 Feb 2005 17:57 GMT
I think I was too hasty posting this query.
Here is the solution:
Dim FoundText as Boolean
Dim FoundTextParagraph as Paragraph
With ActiveDocument.Range.Find
FoundText = .Execute("The text I am searching for")
Set FoundTextParagraph = .Parent.Paragraphs(1)
End With