You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Default template creates documents in Word 2010 compatibility mode ( compatibilityMode=14 ). Propose updating to 15. #1634
Documents created with Document() (no argument) open in Word with a "Compatibility Mode" banner. The built-in template sets compatibilityMode to 14 (Word 2010) instead of 15 , the value used by Word 2013 and later, including current Microsoft 365.
Since AI assistants such as GitHub Copilot started using python-docx, it has become one of the most common ways .docx files get created. Most of these flows call Document() without supplying their own starting file. We're seeing a large spike in new .docx files that open in compatibility mode, which:
• shows users a confusing "Compatibility Mode" banner on brand-new documents,
• turns off newer Word features until the user converts the document,
• and makes the documents lay out with legacy rules instead of current Word behaviour.
The workaround in #1543 (pass your own blank file to Document() ) works, but in practice generated code almost never does this. The default is what most new documents get.
compatibilityMode is set in two bundled files:
• src/docx/templates/default.docx , in word/settings.xml
• src/docx/templates/default-settings.xml , the fallback when a package has no settings part
Change w:val="14" to w:val="15" in both files so Document() and the settings fallback stay consistent. No Python code changes are needed.
Changing the compatibility mode can, in theory, slightly change layout for a small number of documents that depend on Word 2010-era layout rules. We think the risk is acceptable, as we have not observed any layout changes when changing compatibility mode to 15 on our own dataset:
• it only affects newly created documents; existing documents opened with Document(path) keep their own settings,
• the legacy compatibility options tied to mode 14 are expected to be deprecated in Word in the coming months, so documents created in mode 14 will lose that legacy behaviour soon anyway,
• 15 is what current Word writes for every new document, so this only brings python-docx in line with the application.
I'm happy to open a PR with this change (both template files, plus any test updates). Please let me know if you'd prefer this approach, or regenerating default.docx from current Word (which would also refresh styles and theme, but makes a larger diff).
Activity