Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 913 Bytes

File metadata and controls

30 lines (22 loc) · 913 Bytes

Working with custom properties

The custom properties can be accessed/modified by navigating to File menu --> Properties --> Advanced properties --> Customization in Word. These properties are stored in the /docProps/custom.xml file.

we can CRUD them via python-docx-oss:

from docx import Document
document = Document()

>>> print(document.custom_properties["not-exist-key"])
None

>>> document.custom_properties["bjj"] = "oss"
>>> print(document.custom_properties["bjj"])
oss

>>> document.custom_properties["bjj"] = "rnc"
>>> print(document.custom_properties["bjj"])
rnc

>>> document.custom_properties["bjj"] = None
>>> print(document.custom_properties["bjj"])
None

Be careful, users also can see & modify these properties in Word. Use :ref:`customXml<custom_xml>` if you need them hidden.