DOCX Manipulation Skill
Overview
This skill enables programmatic creation, editing, and manipulation of Microsoft Word (.docx) documents using the python-docx library. Create professional documents with proper formatting, styles, tables, and images without manual editing.
How to Use
- Describe what you want to create or modify in a Word document
- Provide any source content (text, data, images)
- I'll generate python-docx code and execute it
Example prompts:
- "Create a professional report with title, headings, and a table"
- "Add a header and footer to this document"
- "Generate a contract document with placeholders"
- "Convert this markdown content to a styled Word document"
Domain Knowledge
python-docx Fundamentals
Document Structure
Adding Content
Paragraphs & Headings
Tables
Images
Formatting
Paragraph Formatting
Character Formatting
Page Setup
Headers & Footers
Styles
Best Practices
- Structure First: Plan document hierarchy before coding
- Use Styles: Consistent formatting via styles, not manual formatting
- Save Often: Call
doc.save()periodically for large documents - Handle Errors: Check file existence before opening
- Clean Up: Remove template placeholders after filling
Common Patterns
Report Template
Table from Data
Mail Merge Pattern
Examples
Example 1: Create a Business Letter
Example 2: Create a Report with Table
Limitations
- Cannot execute macros or VBA code
- Complex templates may lose some formatting
- Limited support for advanced features (SmartArt, Charts)
- No direct PDF conversion (use separate tool)
- Track changes reading is limited



