Home Page (Objects) | Overview | FAQ | Reference
Applies to: TextDocument object
Searches a document for a specified string. If the string is found, the MarkText method marks the lines containing the string with unnamed temporary bookmarks.
Syntax
object.MarkText ( string [, flags] )
Parameters
object
An expression that evaluates to a TextDocument object.
string
A String that is the string you want to find.
flags
(Optional) A Long 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 MarkText method returns one of the following values:
Remarks
You can combine values in the flags parameter by using the or or + operator. 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.
You can move from bookmark to bookmark in a document. First, press CTRL+F2 so that you can move forward or backward. Then, press F2 to move forward, or press SHIFT+F2 to move backward.
Example
The following example conducts a case-sensitive search of the current selection to find the text "TODO" and then marks the lines containing this text with unnamed temporary bookmarks:
Sub MarkMain
ActiveDocument.Selection.MarkText "TODO", dsMatchCase
End Sub
See Also FindText method, ReplaceText method.