✓ Verified 💻 Development ✓ Enhanced Data

Tiangong Wps Word Automation

Automate common Word/WPS document operations on Windows via COM (read text, replace, insert, heading

Rating
4.5 (368 reviews)
Downloads
950 downloads
Version
1.0.0

Overview

Automate common Word/WPS document operations on Windows via COM (read text, replace, insert, headings.

Complete Documentation

View Source →

WPS/Word Automation (Windows)

Use the bundled Python script to control Word or WPS via COM.

Requirements

  • Windows with Microsoft Word or WPS Writer installed.
  • Python + pywin32 (python -m pip install pywin32).

Quick start

bash
python {baseDir}/scripts/wps_word_automation.py read --input "C:\path\file.docx"
python {baseDir}/scripts/wps_word_automation.py replace --input "C:\path\file.docx" --find "旧" --replace "新" --save "C:\path\out.docx"
python {baseDir}/scripts/wps_word_automation.py export --input "C:\path\file.docx" --format pdf --output "C:\path\out.pdf"

Commands

read

Extract plain text.

bash
python {baseDir}/scripts/wps_word_automation.py read --input "C:\path\file.docx" --output "C:\path\out.txt"

replace

Find/replace text.

bash
python {baseDir}/scripts/wps_word_automation.py replace --input "C:\path\file.docx" --find "old" --replace "new" --save "C:\path\out.docx"

insert

Insert text at start/end.

bash
python {baseDir}/scripts/wps_word_automation.py insert --input "C:\path\file.docx" --text "Hello" --where start --save "C:\path\out.docx"

headings

Apply Heading 1/2/3 to matching lines.

bash
python {baseDir}/scripts/wps_word_automation.py headings --input "C:\path\file.docx" --level 1 --prefix "# " --save "C:\path\out.docx"

header-footer

Set header/footer text.

bash
python {baseDir}/scripts/wps_word_automation.py header-footer --input "C:\path\file.docx" --header "标题" --footer "页脚" --save "C:\path\out.docx"

page-break

Insert a page break at the end.

bash
python {baseDir}/scripts/wps_word_automation.py page-break --input "C:\path\file.docx" --save "C:\path\out.docx"

merge

Merge multiple docs into one.

bash
python {baseDir}/scripts/wps_word_automation.py merge --inputs "a.docx" "b.docx" --output "merged.docx"

split

Split by page ranges (e.g., "1-3,4-6").

bash
python {baseDir}/scripts/wps_word_automation.py split --input "C:\path\file.docx" --pages "1-3,4-6" --outdir "C:\out"

export

Export to PDF or TXT.

bash
python {baseDir}/scripts/wps_word_automation.py export --input "C:\path\file.docx" --format pdf --output "C:\path\out.pdf"
python {baseDir}/scripts/wps_word_automation.py export --input "C:\path\file.docx" --format txt --output "C:\path\out.txt"

image

Add or replace image at the end.

bash
python {baseDir}/scripts/wps_word_automation.py image --input "C:\path\file.docx" --image "C:\path\img.png" --save "C:\path\out.docx"

Notes

  • If WPS is installed, try --app wps; otherwise default uses Word.
  • Use --visible true if you need to watch the UI.
  • Avoid batch usage; this skill is for single-document operations.

Installation

Terminal bash

openclaw install tiangong-wps-word-automation
    
Copied!

💻Code Examples

python {baseDir}/scripts/wps_word_automation.py export --input "C:\path\file.docx" --format pdf --output "C:\path\out.pdf"

python-basedirscriptswpswordautomationpy-export---input-cpathfiledocx---format-pdf---output-cpathoutpdf.txt
## Commands

### read
Extract plain text.

python {baseDir}/scripts/wps_word_automation.py read --input "C:\path\file.docx" --output "C:\path\out.txt"

python-basedirscriptswpswordautomationpy-read---input-cpathfiledocx---output-cpathouttxt.txt
### replace
Find/replace text.

python {baseDir}/scripts/wps_word_automation.py replace --input "C:\path\file.docx" --find "old" --replace "new" --save "C:\path\out.docx"

python-basedirscriptswpswordautomationpy-replace---input-cpathfiledocx---find-old---replace-new---save-cpathoutdocx.txt
### insert
Insert text at start/end.

python {baseDir}/scripts/wps_word_automation.py insert --input "C:\path\file.docx" --text "Hello" --where start --save "C:\path\out.docx"

python-basedirscriptswpswordautomationpy-insert---input-cpathfiledocx---text-hello---where-start---save-cpathoutdocx.txt
### headings
Apply Heading 1/2/3 to matching lines.

python {baseDir}/scripts/wps_word_automation.py headings --input "C:\path\file.docx" --level 1 --prefix "# " --save "C:\path\out.docx"

python-basedirscriptswpswordautomationpy-headings---input-cpathfiledocx---level-1---prefix-----save-cpathoutdocx.txt
### header-footer
Set header/footer text.

python {baseDir}/scripts/wps_word_automation.py header-footer --input "C:\path\file.docx" --header "标题" --footer "页脚" --save "C:\path\out.docx"

python-basedirscriptswpswordautomationpy-header-footer---input-cpathfiledocx---header----footer----save-cpathoutdocx.txt
### page-break
Insert a page break at the end.

python {baseDir}/scripts/wps_word_automation.py page-break --input "C:\path\file.docx" --save "C:\path\out.docx"

python-basedirscriptswpswordautomationpy-page-break---input-cpathfiledocx---save-cpathoutdocx.txt
### merge
Merge multiple docs into one.

python {baseDir}/scripts/wps_word_automation.py merge --inputs "a.docx" "b.docx" --output "merged.docx"

python-basedirscriptswpswordautomationpy-merge---inputs-adocx-bdocx---output-mergeddocx.txt
### split
Split by page ranges (e.g., "1-3,4-6").

python {baseDir}/scripts/wps_word_automation.py split --input "C:\path\file.docx" --pages "1-3,4-6" --outdir "C:\out"

python-basedirscriptswpswordautomationpy-split---input-cpathfiledocx---pages-1-34-6---outdir-cout.txt
### export
Export to PDF or TXT.

python {baseDir}/scripts/wps_word_automation.py export --input "C:\path\file.docx" --format txt --output "C:\path\out.txt"

python-basedirscriptswpswordautomationpy-export---input-cpathfiledocx---format-txt---output-cpathouttxt.txt
### image
Add or replace image at the end.

Tags

#git_and-github #automation

Quick Info

Category Development
Model Claude 3.5
Complexity Multi-Agent
Author fadeloo
Last Updated 3/10/2026
🚀
Optimized for
Claude 3.5
🧠

Ready to Install?

Get started with this skill in seconds

openclaw install tiangong-wps-word-automation