当前位置:网站首页>原生方法合并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
边栏推荐
- PCL point cloud to depth image
- 【AI应用】海康威视iVMS-4200软件安装
- What are the software product management systems? Inventory of 12 best product management tools
- spritejs
- III Chip startup and clock system
- [applinking practical case] share in app pictures through applinking
- Calculate the sum of sequences
- Special topic of binary tree -- acwing 1497 Traversal of the tree (use post and mid order traversal to build a binary tree)
- Static variables in static function
- V2x SIM dataset (Shanghai Jiaotong University & New York University)
猜你喜欢
Win11 arm system configuration Net core environment variable
Binary tree topic -- Luogu p3884 [jloi2009] binary tree problem (DFS for binary tree depth BFS for binary tree width Dijkstra for shortest path)
[AGC] build service 3 - authentication service example
【深入浅出玩转FPGA学习5-----复位设计】
【AI应用】海康威视iVMS-4200软件安装
TIPC messaging3
Overview of integrated learning
TIPC Cluster5
How to transfer event objects and user-defined parameters simultaneously in Huawei express applications
Iii. Système de démarrage et d'horloge à puce
随机推荐
V2x SIM dataset (Shanghai Jiaotong University & New York University)
V2X-Sim数据集(上海交大&纽约大学)
金山云——2023届暑期实习
QT learning diary 7 - qmainwindow
mmrotate旋转目标检测框架使用记录
Summary of cases of players' disconnection and reconnection in Huawei online battle service
Special topic of binary tree -- acwing 47 Path with a certain value in binary tree (preorder traversal)
二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)
Approximate sum count (approximate
[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
Functional interfaces and method references
二叉树专题--P1030 [NOIP2001 普及组] 求先序排列
Resources读取2d纹理 转换为png格式
webauthn——官方开发文档
Regular and common formulas
js中给数组添加元素的方法有哪些
TIPC Cluster5
Special topic of binary tree -- acwing 1497 Traversal of the tree (use post and mid order traversal to build a binary tree)
实验电镜距离测量之Matlab处理
PCL eigen introduction and simple use