Skip to content

Exceptions when working with own document #1333

@me21

Description

@me21

I saved an empty docx file in my Microsoft Word. When I open it with python-docx and try to add a heading, I get KeyError: "no style with name 'Heading 1'". My code looks like document.add_heading('Visitor Information', level=1).

If I open that empty document, add a heading of the 1st level, then delete it again, and save the document, the code works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions