Find Property

Microsoft Word Visual Basic

Find Property

       

Returns a Find object that contains the criteria for a find operation. Read-only.

Note   When this property is used with a Selection object, the selection is changed if the find operation is successful. If this property is used with a Range object, the selection isn't changed unless the Select method is applied.

Example

The following example searches forward through the document for the word "Microsoft." If the word is found, it's automatically selected.

With Selection.Find
    .Forward = True
    .ClearFormatting
    .MatchWholeWord = True
    .MatchCase = False
    .Wrap = wdFindContinue
    .Execute FindText:="Microsoft"
End With

This example inserts "Tip: " at the beginning of every paragraph formatted with the Heading 3 style in the active document. The Do…Loop statement is used to repeat a series of actions each time this style is found.

With ActiveDocument.Content.Find
    .ClearFormatting
    .Style = wdStyleHeading3
    Do While .Execute(FindText:="", Forward:=True, _
            Format:=True) = True
        With .Parent
            .StartOf Unit:=wdParagraph, Extend:=wdMove
            .InsertAfter "Tip: "
            .Move Unit:=wdParagraph, Count:=1
        End With
    Loop
End With