Skip to content

Support for '.docm' OOXML format? #212

Open
@3vocati

Description

@3vocati

Hello,

It seems that python-docx does not have any built in support for '.docm' OOXML documents. From the perspective of parsing this document type as a docx, there is not much difference: There are some extra document parts that support the macro language / VBA, and the Content Type for the 'word\document.xml' Document Part is 'application/vnd.ms-word.document.macroEnabled.main+xml'.

Attempting to open a '.docm' with python-docx results in the error code "file '...' is not a Word file, content type is 'application/vnd.ms-word.document.macroEnabled.main+xml'", and it does not even attempt to parse the file.

However, because a docm is basically a docx, I can get python-docx reading and writing docm files by adding the 'application/vnd.ms-word.document.macroEnabled.main+xml' Content Type to 'opc/constants.py', assigning the Content Type to a Part Factory in init.py, and adding the new Content Type to the gatekeeper check in api.py.

Is this a feature you might add to the library? So far, it seems like a small change; I haven't had any issues with my locally patched version yet, though you might know of some gotchas that I haven't encountered yet.

Thank you,

Pete

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