Find Property
As it applies to the Document object.
Returns a FindReplace object. The FindReplace object is used to perform a text search and replace in the specified document.
expression.Find
expression Required. An expression that returns a Document object.
As it applies to the TextRange object.
Returns a FindReplace object from the specified TextRange object. The FindReplace object is used to perform a text search and replace in the specified text range.
expression.Find
expression Required. An expression that returns a TextRange object.
Example
As it applies to the Document object.
The following example sets an object variable to the FindReplace object of the active document. A search operation is executed that applies bold formatting to every occurrence of the word "important".
Dim objFind as FindReplace
Dim fFound as Boolean
Set objFind = ActiveDocument.Find
fFound = True
With objFind
.Clear
.FindText = "important"
Do While fFound = True
fFound = .Execute
If Not .FoundTextRange Is Nothing Then
.FoundTextRange.Font.Bold = True
End If
Loop
End With
As it applies to the TextRange object.
The following example sets an object variable to the FindReplace object of the text range of the first shape in the active document. A search operation is executed that applies bold formatting to every occurrence of the word "urgent" in the text range.
Dim objFind as FindReplace
Dim fFound as Boolean
Set objFind = ActiveDocument.Pages(1) _
.Shapes(1).TextFrame.TextRange.Find
fFound = True
With objFind
.Clear
.FindText = "urgent"
Do While fFound = True
fFound = .Execute
If Not .FoundTextRange Is Nothing Then
.FoundTextRange.Font.Bold = True
End If
Loop
End With