当前位置:网站首页>原生方法合并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
边栏推荐
- spritejs
- php中self和static在方法中的区别
- Calculate the sum of sequences
- [play with FPGA learning 4 in simple terms ----- talk about state machine design]
- TIPC Getting Started6
- Verilog and VHDL signed and unsigned number correlation operations
- K-d tree and octree of PCL
- 二叉树专题--AcWing 19. 二叉树的下一个节点(找树中节点的后继)
- C file and folder operation
- Approximate sum count (approximate
猜你喜欢

JVM之垃圾回收器

From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang

TIPC Cluster5

Overview of integrated learning
![[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched](/img/5c/b0030fd5fbc07eb94013f2699c2a04.png)
[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched

enumrate的start属性的坑

Flick two open, realized a batch lookup join (with source code)
![[play with FPGA learning 5 in simple terms ----- reset design]](/img/57/816a59787259dc32b52897c069e1a6.png)
[play with FPGA learning 5 in simple terms ----- reset design]

二叉树专题--AcWing 3540. 二叉搜索树建树(实用板子 构建二叉搜索树 并输出前、中、后序遍历)

Use of vscode tool
随机推荐
spritejs
Luogu p5536 [xr-3] core city (greed + tree DP looking for the center of the tree)
[AGC] build service 3 - authentication service example
二叉树专题--洛谷 P3884 [JLOI2009]二叉树问题(dfs求二叉树深度 bfs求二叉树宽度 dijkstra求最短路)
ctf 记录
One trick to quickly realize custom application titlebar
MTK full dump grab
Static variables in static function
LVM operation
The most detailed MySQL installation tutorial
sqlite 修改列类型
QT learning diary 8 - resource file addition
TIPC messaging3
Leetcode 182 Find duplicate email (2022.07.01)
Special topic of binary tree -- acwing 1589 Building binary search tree
Jenkins安装
V2X-Sim数据集(上海交大&纽约大学)
Overview of integrated learning
【深入浅出玩转FPGA学习4----漫谈状态机设计】
Complement (Mathematical Simulation