フィールドのプロパティを検索する

Contents
[ ]

DocumentBuilder.insert_field を使用して挿入されたフィールドは Field オブジェクトを返します。これは、フィールドのいくつかのプロパティをすばやく検索するための便利なメソッドを提供するファサード クラスです。

次のコード例は、フィールド コードとフィールド結果を検索する方法を示しています。

# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET
doc = aw.Document(MY_DIR + "Hyperlinks.docx")
for field in doc.range.fields:
field_code = field.get_field_code()
field_result = field.result

文書内の差し込みフィールドの名前のみを検索する場合は、代わりに組み込みの get_field_names メソッドを使用できることに注意してください。

次のコード例は、ドキュメント内のすべての差し込みフィールドの名前を取得する方法を示しています。

# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET
doc = aw.Document()
fieldNames = doc.mail_merge.get_field_names()