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 のサポートおよびフィードバックを参照してください。