count property

DocumentPropertyCollection.count property

Gets number of items in the collection.

@property
def count(self) -> int:
    ...

Examples

Shows how to work with custom document properties.

doc = aw.Document(MY_DIR + "Properties.docx")

# Every document contains a collection of custom properties, which, like the built-in properties, are key-value pairs.
# The document has a fixed list of built-in properties. The user creates all of the custom properties.
self.assertEqual("Value of custom document property", str(doc.custom_document_properties.get_by_name("CustomProperty")))

doc.custom_document_properties.add("CustomProperty2", "Value of custom document property #2")

print("Custom Properties:")
for custom_document_property in doc.custom_document_properties:
    print(custom_document_property.name)
    print(f"\tType:\t{custom_document_property.type}")
    print(f"\tValue:\t\"{custom_document_property.value}\"")

See Also