Find Field Properties

Contents
[ ]

A field that is inserted using DocumentBuilder.insert_field returns a Field object. This is a faсade class that provides useful methods to quickly find some properties of a field.

The following code example shows how to find the field code and field result:

# 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

Note if you are only looking for the names of merge fields in a document, then you can instead use the built-in get_field_names method.

The following code example shows how to get names of all merge fields in a document:

# 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()