Document.Find 屬性 (Publisher)
會從指定的Document物件傳回FindReplace物件。 使用 FindReplace 物件可在指定文件中搜尋和取代文字。
語法
運算式。找到
表達 代表 Document 物件的變數。
範例
適用于 Document 物件。 下列範例會將使用中文件的 FindReplace 物件的物件變數。 執行的搜尋作業會將粗體格式套用至每次出現的字組重要。
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
適用于 TextRange 物件。 下列範例會將使用中文件的第一個圖案之文字範圍的 FindReplace 物件的物件變數。 會執行搜尋作業,將粗體格式套用至文字範圍中每一個出現的「緊急」一詞。
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
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。