当前位置:网站首页>原生方法合并word
原生方法合并word
2022-07-02 09:32:00 【nongcunqq】
import os
#输入输出函数,用来获取目录路径
import win32com.client as win32
word = win32.gencache.EnsureDispatch('Word.Application')
#启动word对象应用
word.Visible = False #是否可视化,如果改为True,则会在电脑上频繁出现word文档界面
path = r'D:\word'
#存放文件路径
files = []
for filename in os.listdir(path):
filename = os.path.join(path,filename)
files.append(filename)
#获取目录下所有文件的路径
output = word.Documents.Add()
#print(output)
print(files)
#新建空的word文档,
for file in files:
output.Application.Selection.InsertFile(file)
#拼接文档
doc = output.Range(output.Content.Start, output.Content.End)
#获取合并后文档的内容
output.SaveAs('D://word//result.docx') #保存
output.Close()#关闭
参考
https://blog.csdn.net/weixin_44999258/article/details/125163277
边栏推荐
- TIPC protocol
- [in simple terms, play with FPGA learning 3 ----- basic grammar]
- [paid promotion] collection of frequently asked questions, recommended list FAQ
- MTK full dump抓取
- Special topic of binary tree -- acwing 47 Path with a certain value in binary tree (preorder traversal)
- Special topic of binary tree -- acwing 3540 Binary search tree building (use the board to build a binary search tree and output the pre -, middle -, and post sequence traversal)
- 主键策略问题
- [AGC] build service 3 - authentication service example
- Matlab processing of distance measurement of experimental electron microscope
- 二叉树专题--P1030 [NOIP2001 普及组] 求先序排列
猜你喜欢

二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)

Tick Data and Resampling

How does the whole network display IP ownership?

PHP tea sales and shopping online store

Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)

金山云——2023届暑期实习

enumrate的start属性的坑

Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)

Flick two open, realized a batch lookup join (with source code)

Uncover the secrets of Huawei application market application statistics
随机推荐
Tick Data and Resampling
TIPC messaging3
Jinshanyun - 2023 Summer Internship
MTK full dump抓取
Uncover the secrets of Huawei application market application statistics
Tick Data and Resampling
Openmldb meetup No.4 meeting minutes
String (Analog
Multi line display and single line display of tqdm
Gaode draws lines according to the track
spritejs
How to transfer event objects and user-defined parameters simultaneously in Huawei express applications
How to implement tabbar title bar with list component
从攻击面视角,看信创零信任方案实践
LVM操作
V2x SIM dataset (Shanghai Jiaotong University & New York University)
The most detailed MySQL installation tutorial
SQLite modify column type
ASTParser 解析含有emum 枚举方法的类文件的踩坑记
Luogu p5536 [xr-3] core city (greed + tree DP looking for the center of the tree)