René's URL Explorer Experiment


Title: feat: open and save .docm, .dotx and .dotm files by BenoitMarchand · Pull Request #1644 · python-openxml/python-docx · GitHub

Open Graph Title: feat: open and save .docm, .dotx and .dotm files by BenoitMarchand · Pull Request #1644 · python-openxml/python-docx

X Title: feat: open and save .docm, .dotx and .dotm files by BenoitMarchand · Pull Request #1644 · python-openxml/python-docx

Description: Summary Open and save macro-enabled documents (.docm), templates (.dotx) and macro-enabled templates (.dotm). The package kind is preserved on save and the VBA project is carried along byte for byte. Fixes #212, fixes #363. Addresses the file-format part of #284 (macros are preserved, not readable or editable). Why another PR on this Several PRs make the same code change (#673, #716, #1378, #1407). On #673 you said it could not be accepted without analysis documentation and tests, and that the analysis should cover how macros are stored in the package, document experiments showing they are preserved on save, and discuss where the approach may be insufficient or have unintended consequences. This PR adds those: Analysis page docs/dev/analysis/features/document-kinds.rst: how the four kinds differ (only the main document part content type), how macros are stored (vbaProject.bin, vbaData.xml, relationships, optional signature, keymap and ActiveX parts) and why they round-trip: they load as generic Part objects, the experiments and their results, limits: macros are opaque, no conversion between kinds, extension/content-type mismatch, signatures, parts reachable only by relationship, templates edited in place. Unit tests: docx.Document() is parametrized over the four content types. Acceptance tests in api-open-document.feature: open each kind, save and reload, checking the content type is unchanged and vbaProject.bin is byte-identical. The .docm/.dotm fixtures carry a real VBA project saved by Word. User docs (documents.rst) and a HISTORY entry. Change opc/constants.py: add WML_DOCUMENT_MACRO_MAIN, WML_TEMPLATE_MAIN and WML_TEMPLATE_MACRO_MAIN. __init__.py: map those content types to DocumentPart. api.py: accept the four main-document content types. No new public API. Behaviour for .docx is unchanged. Experiments (summary; details on the analysis page) Word-made .docm, .dotx and .dotm files covering most python-docx features (tables, images in 5 formats, comments, 4 sections with headers and footers) were used. The macro files contain a VBA module with a probe macro. Results: python-docx 1.2.0 (PyPI): the .docx opens; the other three raise ValueError: ... is not a Word file. This branch, after load, edit and save: content type is unchanged; no parts are lost or added; vbaProject.bin and every image are byte-identical; the VBA relationships are intact; the VBA source extracted with oletools still contains the macros. Back in Word: the saved files open without a repair prompt, and the probe macro runs and detects the paragraph added by python-docx. Checks pytest: 1612 passed behave: 656 scenarios passed ruff check and ruff format --check: clean pyright: no new errors 🤖 Generated with Claude Code

Open Graph Description: Summary Open and save macro-enabled documents (.docm), templates (.dotx) and macro-enabled templates (.dotm). The package kind is preserved on save and the VBA project is carried along byte for byt...

X Description: Summary Open and save macro-enabled documents (.docm), templates (.dotx) and macro-enabled templates (.dotm). The package kind is preserved on save and the VBA project is carried along byte for byt...

Opengraph URL: https://github.com/python-openxml/python-docx/pull/1644

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:535b5860-2f4d-5ae2-681d-c73d6058ddb7
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD5C4:178BB9:7AEC97:8F15B6:6AFF65D1
html-safe-nonce1fa124615629f37ab9decd91137ffe83fb5acea32ddba9d773448ece385e5a75
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENUM0OjE3OEJCOTo3QUVDOTc6OEYxNUI2OjZBRkY2NUQxIiwidmlzaXRvcl9pZCI6IjUxMjY1NDQ1Mzc2MzU3NDMxODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac7baa84958ecceaca2a1b67c9d0fb10ff82847adb7382bfa9a9b4ae86df860229
hovercard-subject-tagpull_request:5232775060
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python-openxml/python-docx/pull/1644/files
twitter:imagehttps://avatars.githubusercontent.com/u/26932424?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/26932424?s=400&v=4
og:image:altSummary Open and save macro-enabled documents (.docm), templates (.dotx) and macro-enabled templates (.dotm). The package kind is preserved on save and the VBA project is carried along byte for byt...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None41b58589a1c4eda1e3c8904144a412b88ca4455f63ca2ad3629f2e9f3c3a1d12
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python-openxml/python-docx git https://github.com/python-openxml/python-docx.git
octolytics-dimension-user_id3403760
octolytics-dimension-user_loginpython-openxml
octolytics-dimension-repository_id13592924
octolytics-dimension-repository_nwopython-openxml/python-docx
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id13592924
octolytics-dimension-repository_network_root_nwopython-openxml/python-docx
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8968d6d6acc65d74e4df332d23932dd3fd0502a4
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-openxml/python-docx/pull/1644/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-openxml%2Fpython-docx%2Fpull%2F1644%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-openxml%2Fpython-docx%2Fpull%2F1644%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python-openxml%2Fpython-docx
Reloadhttps://github.com/python-openxml/python-docx/pull/1644/files
Reloadhttps://github.com/python-openxml/python-docx/pull/1644/files
Reloadhttps://github.com/python-openxml/python-docx/pull/1644/files
python-openxmlhttps://github.com/python-openxml
python-docxhttps://github.com/python-openxml/python-docx
Codehttps://github.com/python-openxml/python-docx
Issues387 (387)https://github.com/python-openxml/python-docx/issues
Pull requests167 (167)https://github.com/python-openxml/python-docx/pulls
Actionshttps://github.com/python-openxml/python-docx/actions
Projectshttps://github.com/python-openxml/python-docx/projects
Wikihttps://github.com/python-openxml/python-docx/wiki
Security and qualityhttps://github.com/python-openxml/python-docx/security
Insightshttps://github.com/python-openxml/python-docx/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython-openxml%2Fpython-docx%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython-openxml%2Fpython-docx%2Fissues%2Fnew%2Fchoose
BenoitMarchandhttps://github.com/BenoitMarchand
python-openxml:masterhttps://github.com/python-openxml/python-docx/tree/master
BenoitMarchand:feat/212-363-docm-dotx-dotmhttps://github.com/BenoitMarchand/python-docx/tree/feat/212-363-docm-dotx-dotm
Conversation 0 https://github.com/python-openxml/python-docx/pull/1644
Commits 2 https://github.com/python-openxml/python-docx/pull/1644/commits
Checks 0 https://github.com/python-openxml/python-docx/pull/1644/checks
Files changed https://github.com/python-openxml/python-docx/pull/1644/files
Please reload this pagehttps://github.com/python-openxml/python-docx/pull/1644/files
feat: open and save .docm, .dotx and .dotm files https://github.com/python-openxml/python-docx/pull/1644/files#top
Show all changes 2 commits https://github.com/python-openxml/python-docx/pull/1644/files
38977fa feat: open and save .docm, .dotx and .dotm files BenoitMarchand Nov 9, 2026 https://github.com/python-openxml/python-docx/pull/1644/commits/38977fa63e37db9afbcae614cbe72b8f73c8624f
b11a2c7 docs: expand .docm/.dotx/.dotm analysis, use real VBA in fixtures BenoitMarchand Nov 9, 2026 https://github.com/python-openxml/python-docx/pull/1644/commits/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87
Clear filters https://github.com/python-openxml/python-docx/pull/1644/files
Please reload this pagehttps://github.com/python-openxml/python-docx/pull/1644/files
Please reload this pagehttps://github.com/python-openxml/python-docx/pull/1644/files
HISTORY.rst https://github.com/python-openxml/python-docx/pull/1644/files#diff-e2de3cbc57ab9b097fca7d7c444c094ba3c1d4ee92b36d972d0d9d49669436cc
document-kinds.rst https://github.com/python-openxml/python-docx/pull/1644/files#diff-827e33389dac8a286ba74a54ea3491305591e6136a5b0d12bc5a2780cda2d6f9
index.rst https://github.com/python-openxml/python-docx/pull/1644/files#diff-804ea4a26526b00e550e5897049ba93bc0e90d546ad46d11119bffbeab84bf38
documents.rst https://github.com/python-openxml/python-docx/pull/1644/files#diff-090ca17dd9cc5f9dc7867d268853808537ecb239448998acf6dfc62e66e29366
api-open-document.feature https://github.com/python-openxml/python-docx/pull/1644/files#diff-d6a2d1605a2f2ec0a6aef6ba01f242b3cf85a86cf110b10e8a39e600810a15da
api.py https://github.com/python-openxml/python-docx/pull/1644/files#diff-60fb2c3d0fa6a202ec247b8cb09eab39b177fc03729ffd4b1708783bc3701b8d
doc-default.docm https://github.com/python-openxml/python-docx/pull/1644/files#diff-77605054a0d21991277a485c36235ebf0b0ae030cda590aebe894ce3c4bd90fb
doc-default.dotm https://github.com/python-openxml/python-docx/pull/1644/files#diff-d5d2e02fd3971130aa26e9e2f979bad9fefe13476362af2a6684b649f4839670
doc-default.dotx https://github.com/python-openxml/python-docx/pull/1644/files#diff-61e766325f9e59b53bc45258998944c262885ce10999ec5363be93702bd3ab49
__init__.py https://github.com/python-openxml/python-docx/pull/1644/files#diff-c0bf42026978200784773e804db3ffff39372f9455f2152da258374d3d10d136
api.py https://github.com/python-openxml/python-docx/pull/1644/files#diff-e38e9452de6c2f423a4b549b831e0315df907a7468f737933dbf2268dc2a7261
constants.py https://github.com/python-openxml/python-docx/pull/1644/files#diff-32e25bb0f15a088c4a9f04b97ba70adde55e7da1eddacb58966f029810f1d530
test_api.py https://github.com/python-openxml/python-docx/pull/1644/files#diff-3451cc474d5698222168f66a293339a6bd296ee2c56f56409866bbae99917a79
HISTORY.rsthttps://github.com/python-openxml/python-docx/pull/1644/files#diff-e2de3cbc57ab9b097fca7d7c444c094ba3c1d4ee92b36d972d0d9d49669436cc
View file https://github.com/python-openxml/python-docx/blob/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87/HISTORY.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-openxml/python-docx/pull/1644/{{ revealButtonHref }}
https://github.com/python-openxml/python-docx/pull/1644/files#diff-e2de3cbc57ab9b097fca7d7c444c094ba3c1d4ee92b36d972d0d9d49669436cc
https://github.com/python-openxml/python-docx/pull/1644/files#diff-e2de3cbc57ab9b097fca7d7c444c094ba3c1d4ee92b36d972d0d9d49669436cc
docs/dev/analysis/features/document-kinds.rsthttps://github.com/python-openxml/python-docx/pull/1644/files#diff-827e33389dac8a286ba74a54ea3491305591e6136a5b0d12bc5a2780cda2d6f9
View file https://github.com/python-openxml/python-docx/blob/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87/docs/dev/analysis/features/document-kinds.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-openxml/python-docx/pull/1644/{{ revealButtonHref }}
docs/dev/analysis/index.rsthttps://github.com/python-openxml/python-docx/pull/1644/files#diff-804ea4a26526b00e550e5897049ba93bc0e90d546ad46d11119bffbeab84bf38
View file https://github.com/python-openxml/python-docx/blob/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87/docs/dev/analysis/index.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-openxml/python-docx/pull/1644/{{ revealButtonHref }}
https://github.com/python-openxml/python-docx/pull/1644/files#diff-804ea4a26526b00e550e5897049ba93bc0e90d546ad46d11119bffbeab84bf38
https://github.com/python-openxml/python-docx/pull/1644/files#diff-804ea4a26526b00e550e5897049ba93bc0e90d546ad46d11119bffbeab84bf38
docs/user/documents.rsthttps://github.com/python-openxml/python-docx/pull/1644/files#diff-090ca17dd9cc5f9dc7867d268853808537ecb239448998acf6dfc62e66e29366
View file https://github.com/python-openxml/python-docx/blob/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87/docs/user/documents.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-openxml/python-docx/pull/1644/{{ revealButtonHref }}
https://github.com/python-openxml/python-docx/pull/1644/files#diff-090ca17dd9cc5f9dc7867d268853808537ecb239448998acf6dfc62e66e29366
https://github.com/python-openxml/python-docx/pull/1644/files#diff-090ca17dd9cc5f9dc7867d268853808537ecb239448998acf6dfc62e66e29366
features/api-open-document.featurehttps://github.com/python-openxml/python-docx/pull/1644/files#diff-d6a2d1605a2f2ec0a6aef6ba01f242b3cf85a86cf110b10e8a39e600810a15da
View file https://github.com/python-openxml/python-docx/blob/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87/features/api-open-document.feature
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-openxml/python-docx/pull/1644/{{ revealButtonHref }}
https://github.com/python-openxml/python-docx/pull/1644/files#diff-d6a2d1605a2f2ec0a6aef6ba01f242b3cf85a86cf110b10e8a39e600810a15da
features/steps/api.pyhttps://github.com/python-openxml/python-docx/pull/1644/files#diff-60fb2c3d0fa6a202ec247b8cb09eab39b177fc03729ffd4b1708783bc3701b8d
View file https://github.com/python-openxml/python-docx/blob/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87/features/steps/api.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-openxml/python-docx/pull/1644/{{ revealButtonHref }}
https://github.com/python-openxml/python-docx/pull/1644/files#diff-60fb2c3d0fa6a202ec247b8cb09eab39b177fc03729ffd4b1708783bc3701b8d
https://github.com/python-openxml/python-docx/pull/1644/files#diff-60fb2c3d0fa6a202ec247b8cb09eab39b177fc03729ffd4b1708783bc3701b8d
features/steps/test_files/doc-default.docmhttps://github.com/python-openxml/python-docx/pull/1644/files#diff-77605054a0d21991277a485c36235ebf0b0ae030cda590aebe894ce3c4bd90fb
View file https://github.com/python-openxml/python-docx/blob/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87/features/steps/test_files/doc-default.docm
Open in desktop https://desktop.github.com
features/steps/test_files/doc-default.dotmhttps://github.com/python-openxml/python-docx/pull/1644/files#diff-d5d2e02fd3971130aa26e9e2f979bad9fefe13476362af2a6684b649f4839670
View file https://github.com/python-openxml/python-docx/blob/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87/features/steps/test_files/doc-default.dotm
Open in desktop https://desktop.github.com
features/steps/test_files/doc-default.dotxhttps://github.com/python-openxml/python-docx/pull/1644/files#diff-61e766325f9e59b53bc45258998944c262885ce10999ec5363be93702bd3ab49
View file https://github.com/python-openxml/python-docx/blob/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87/features/steps/test_files/doc-default.dotx
Open in desktop https://desktop.github.com
src/docx/__init__.pyhttps://github.com/python-openxml/python-docx/pull/1644/files#diff-c0bf42026978200784773e804db3ffff39372f9455f2152da258374d3d10d136
View file https://github.com/python-openxml/python-docx/blob/b11a2c7a53dfe3cdba9869f368d06cd9e550fc87/src/docx/__init__.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-openxml/python-docx/pull/1644/{{ revealButtonHref }}
https://github.com/python-openxml/python-docx/pull/1644/files#diff-c0bf42026978200784773e804db3ffff39372f9455f2152da258374d3d10d136
https://github.com/python-openxml/python-docx/pull/1644/files#diff-c0bf42026978200784773e804db3ffff39372f9455f2152da258374d3d10d136
Please reload this pagehttps://github.com/python-openxml/python-docx/pull/1644/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.