python-openxml / python-docx

Create and modify Word documents with Python
MIT License
4.54k stars 1.11k forks source link

Newer version python 3.7+ not reading .docm #1356

Closed NTC4818 closed 6 months ago

NTC4818 commented 6 months ago

Curious if there is an explanation around .docm files and why they might not be read in newer versions of python. Found this when upgrading aws lambda versions recently and curious how I might go about continuing this functionality even though it may be slightly incorrect.

scanny commented 6 months ago

Hmm, I'm not sure the Python version has anything to do with it. There are some slight differences in the .DOCM package, I believe related mostly to the "content-type" (MIME-type roughly) associated with the main document part when it is macro-enabled. There's been some work on this, maybe have a look through the PRs (I'd start with Google for that) and you should find the gist of what it would take and maybe some working code modifications. https://github.com/python-openxml/python-docx/blob/master/src/docx/opc/constants.py#L201-L203

NTC4818 commented 6 months ago

Looks like this pull request is still yet to be added which might have the functionality. Testing now. https://github.com/python-openxml/python-docx/pull/716/files

NTC4818 commented 6 months ago

Works great, might be worth a merge.