FindText Method

Home Page (Objects)OverviewFAQReference

Applies to: TextSelection object

Starting after the current selection, FindText searches the rest of a document for a specified string. If the string is found, FindText moves the selection to that string.

Syntax

object.FindText ( string [, flags] )

Parameters

object

An expression that evaluates to a TextSelection object.

string

A String that represents the string you want to find.

flags

(Optional) A string constant of type DsTextSearchOptions that determines how to conduct the search. To perform complex searches, you can combine values. The values you can use singly or in combination are:

Return Values

The FindText method returns one of the following values:

Remarks

You can combine values in the flags parameter by using the Or (or) or Concatenation (+) operators. For example, to conduct a case-sensitive forward search, you could specify dsMatchForward or dsMatchCase or dsMatchForward + dsMatchCase. However, you can use only one of the regular expression values at a time. For example, you cannot combine dsMatchRegExpCur with dsMatchRegExpE.

Example

The following example conducts a case-sensitive search for the word "main":

Sub FindMain
   ActiveDocument.Selection.FindText    "main",dsMatchCase + dsMatchWord
End Sub

See Also   MarkText method, ReplaceText method.