I have a beautiful .docx file generated by a teammate and I would like to use the styles in it as defaults for the new documents I am generating programmatically via python-docx.
I am able to load the existing docx file but it isn’t clear how to use the styles from the document in my newly created documents.
Would I need to perform the following pseudo code for each style I use from the existing file?
# Read in our template file to enable style reuse
template = Document("MyTemplate.docx")
# Create our new, empty document
doc = Document()
set_style(doc.styles['Heading 1'] = template.styles['Heading 1']
set_style(doc.styles['Title'] = template.styles['Title']
# etc