Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

How can I locate a paragraph using the .find method ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jamie Carper - 15 Feb 2005 17:23 GMT
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



Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.