当前位置:网站首页>原生方法合并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
边栏推荐
- ctf 记录
- 二叉树专题--洛谷 P1229 遍历问题(乘法原理 已知前、后序遍历求中序遍历个数)
- Gaode draws lines according to the track
- MTK full dump grab
- Why does LabVIEW lose precision in floating point numbers
- Leetcode 182 Find duplicate email (2022.07.01)
- Multi line display and single line display of tqdm
- Supermarket (heap overload
- MTK full dump抓取
- Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)
猜你喜欢

金山云——2023届暑期实习

OpenMLDB Meetup No.4 会议纪要

V2x SIM dataset (Shanghai Jiaotong University & New York University)

Huawei game failed to initialize init with error code 907135000

从攻击面视角,看信创零信任方案实践
![[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?](/img/66/674a06d8e45a31ae879b81554ef373.png)
[AGC] how to solve the problem that the local display of event analysis data is inconsistent with that in AGC panel?

二叉树专题--洛谷 P1229 遍历问题(乘法原理 已知前、后序遍历求中序遍历个数)

Implement custom drawer component in quick application

Importerror: impossible d'importer le nom « graph» de « graphviz»
![[play with FPGA learning 2 in simple terms ----- design skills (basic grammar)]](/img/50/22f2fa8fd606572b13a18cc889ca2e.png)
[play with FPGA learning 2 in simple terms ----- design skills (basic grammar)]
随机推荐
QT学习日记7——QMainWindow
sql left join 主表限制条件写在on后面和写在where后面的区别
启牛商学院给的股票账户安全吗?能开户吗?
enumrate的start属性的坑
TIPC 寻址2
[play with FPGA learning 4 in simple terms ----- talk about state machine design]
洛谷 P3398 仓鼠找 sugar(树上倍增 lca 判断树中两条路径是否相交 结论)
Special topic of binary tree -- acwing 1497 Traversal of the tree (use post and mid order traversal to build a binary tree)
What are the methods of adding elements to arrays in JS
JVM之垃圾回收器
Static variables in static function
Luogu p1892 [boi2003] Gang (and search for variant anti set)
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
MTK full dump grab
spritejs
通过券商经理的开户二维码开股票账户安全吗?还是去证券公司开户安全?
【深入浅出玩转FPGA学习2----设计技巧(基本语法)】
flink二开,实现了个 batch lookup join(附源码)
PCL extracts a subset from a point cloud
How to implement tabbar title bar with list component