Share via


findText Method

Searches for text in the document, and positions the start and end points of the range to encompass the search string and returns a Boolean that represents whether the search was successful.

expression.findText(String, Count, flags)

*expression   * Required. An expression that returns one of the objects in the Applies To list.

String    Required String. Specifies the text to find.

Count    Optional Long. Specifies the number of characters to search from the starting point of the range. A positive integer indicates a forward search; a negative integer indicates a backward search.

flags

2 Matches whole words only.
4 Matches case.

Example

The following example searches the active document for the specified text, and then selects the text if it is found.

Dim objRange As IHTMLTxtRange
Dim blnFound As Boolean

Set objRange = ActiveDocument.body.createTextRange
blnFound = objRange.findText("search text")
If blnFound = True Then objRange.Select

Applies to | IHTMLTxtRange Object