# DOCX Manipulation

Create, edit, and manipulate Word documents programmatically using python-docx

- Repository: https://github.com/claude-office-skills/skills (556 stars)
- Category: Documents
- License: MIT
- Last updated: 2026-01-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add claude-office-skills/skills --skill docx-manipulation -g -a claude-code -y`
Codex: `npx skills add claude-office-skills/skills --skill docx-manipulation -g -a codex -y`
Cursor: `npx skills add claude-office-skills/skills --skill docx-manipulation -g -a cursor -y`
Gemini CLI: `npx skills add claude-office-skills/skills --skill docx-manipulation -g -a gemini-cli -y`

## Description

Create, edit, and manipulate Word documents programmatically using python-docx

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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

1. Describe what you want to create or modify in a Word document
2. Provide any source content (text, data, images)
3. 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

```python
from docx import Document
from docx.shared import Inches, Pt, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.style import WD_STYLE_TYPE

# Create new document
doc = Document()

# Or open existing
doc = Document('existing.docx')
```

### Document Structure
```
Document
├── sections (margins, orientation, size)
├── paragraphs (text with formatting)
├── tables (rows, cells, merged cells)
├── pictures (inline images)
└── styles (predefined formatting)
```

### Adding Content

#### Paragraphs & Headings
```python
# Add heading (level 0-9)
doc.add_heading('Main Title', level=0)
doc.add_heading('Section Title', level=1)

# Add paragraph
para = doc.add_paragraph('Normal text here')

# Add styled paragraph
doc.add_paragraph('Note: Important!', style='Intense Quote')

# Add with inline formatting
para = doc.add_paragraph()
para.add_run('Bold text').bold = True
para.add_run(' and ')
para.add_run('italic text').italic = True
```

#### Tables
```python
# Create table
table = doc.add_table(rows=3, cols=3)
table.style = 'Table Grid'

# Add content
table.cell(0, 0).text = 'Header 1'
table.rows[0].cells[1].text = 'Header 2'

# Add row dynamically
row = table.add_row()
row.cells[0].text = 'New data'

The rest: https://github.com/claude-office-skills/skills/blob/HEAD/docx-manipulation/SKILL.md
