docx

Read, create, and edit Microsoft Word .docx files with text, tables, images, and tracked changes.

57.2k|7.0k|Updated Dec 28, 2025
Ready to run
npx skills add https://github.com/HKUDS/DeepTutor --skill docx-hkuds
💬 Prompt for ChatGPT / Claude Chat▼
Please help me install this Agent Skill.
Skill: docx
Source: https://github.com/HKUDS/DeepTutor/tree/main/deeptutor/skills/builtin/docx
Command: npx skills add https://github.com/HKUDS/DeepTutor --skill docx-hkuds

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires python-docx, and includes scripts (resource) and references (resource) components.

What problem does it solve? Manually creating, editing, or extracting data from Word documents is time-consuming and error-prone. This Skill automates document generation, data extraction, and complex edits including tracked changes and comments, eliminating manual Word operations. ## Core Features & Use Cases - Read & Extract: Pull text, tables, headers, and footers from existing .docx files; parse tracked changes and comments from XML. - Create & Generate: Build Word documents from scratch with formatted text, multi-level headings, styled lists, tables, images, page breaks, headers/footers, page numbers, and tables of contents. - Edit Existing: Find-and-replace content while preserving formatting, apply redlines and comments, or make exact-fidelity modifications to specific XML parts. - Use Case: Generate a quarterly financial report with a title, executive summary paragraph, a metrics table with revenue and growth figures, a chart image, and page numbers in the footer—all in one operation. ## Quick Start Create a new Word document with a heading, a table of key metrics, and save it as report.docx.

Frequently Asked Questions about docx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Word document with a table in Python?▼

Use python-docx to instantiate a Document, call add_table(rows=1, cols=N) to create a table with a header row, then populate cells by indexing rows and columns. Apply a built-in table style like 'Light Grid Accent 1' for formatting.

How do I extract text and tables from an existing .docx file?▼

Load the document with Document('file.docx'), iterate doc.paragraphs to collect body text, and iterate doc.tables to access rows and cells. Each table row is accessed via tbl.rows[i].cells to extract cell text.

Can python-docx read tracked changes and comments?▼

No—python-docx ignores tracked changes. Parse the XML directly using zipfile to read word/document.xml and extract w:ins and w:del elements. Comments require reading word/comments.xml separately.

How do I add page numbers to a Word document footer?▼

Page numbers are Word fields, not simple text. Inject field XML into the footer paragraph using OxmlElement and the w:instrText element with 'PAGE' as the instruction, following the Word field structure.

What happens if I try to edit a .doc file instead of .docx?▼

python-docx cannot read legacy .doc binary format. If needed, convert .doc to .docx using LibreOffice soffice command-line tool, then process with python-docx.

Why does find-and-replace sometimes miss text across multiple runs?▼

Word splits text across runs internally even though p.text shows it whole. If a placeholder spans runs, set the first run's text to the full replaced value and clear remaining runs to collapse formatting.