Skip to content

Phase D.24: .docm macro-enabled file support #37

@loadfix

Description

@loadfix

Support opening and saving .docm (macro-enabled) Word files without stripping macros.

Current behavior

Opening a .docm and saving it strips the VBA project because python-docx doesn't preserve the vbaProject.bin part.

API Design

  • Document(path) — auto-detect .docm and preserve macro parts
  • document.save('output.docm') — save with macros preserved
  • document.has_macros — bool indicating if VBA project is present

Implementation

  • Preserve the vbaProject.bin binary part and its relationship during round-trip
  • Use correct content type for .docm: application/vnd.ms-word.document.macroEnabled.12
  • Don't modify or parse the VBA part — just preserve it

Upstream: python-openxml#284, python-openxml#716 (29+16 = 45 comments)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestphase-dQuality of Life

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions