当前位置:网站首页>原生方法合并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
边栏推荐
- Binary tree topic -- p1030 [noip2001 popularization group] find the first order
- 二叉树专题--AcWing 47. 二叉树中和为某一值的路径(前序遍历)
- 二叉树专题--AcWing 1589. 构建二叉搜索树
- 二.Stm32f407芯片GPIO编程,寄存器操作,库函数操作和位段操作
- Special topic of binary tree -- acwing 1589 Building binary search tree
- What are the methods of adding elements to arrays in JS
- mmrotate旋转目标检测框架使用记录
- Leetcode 182 Find duplicate email (2022.07.01)
- flink二开,实现了个 batch lookup join(附源码)
- 三.芯片啟動和時鐘系統
猜你喜欢

TIPC Service and Topology Tracking4

金山云——2023届暑期实习

mmrotate旋转目标检测框架使用记录
![[AGC] build service 3 - authentication service example](/img/89/63f367270e806e89c4ff92360dc3c5.png)
[AGC] build service 3 - authentication service example

How does the whole network display IP ownership?

Verilog and VHDL signed and unsigned number correlation operations

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

Use of vscode tool

How to use ide to automatically sign and debug Hongmeng application

二叉树专题--AcWing 19. 二叉树的下一个节点(找树中节点的后继)
随机推荐
TIPC messaging3
二叉树专题--AcWing 1589. 构建二叉搜索树
C file and folder operation
【深入浅出玩转FPGA学习2----设计技巧(基本语法)】
Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)
Implementation of six singleton modes
QT学习日记8——资源文件添加
tidb-dm报警DM_sync_process_exists_with_error排查
MTK full dump grab
启牛商学院给的股票账户安全吗?能开户吗?
Jenkins installation
洛谷 P3398 仓鼠找 sugar(树上倍增 lca 判断树中两条路径是否相交 结论)
ctf 记录
Filtering of PCL
Leetcode 182 Find duplicate email (2022.07.01)
【深入浅出玩转FPGA学习5-----复位设计】
Openmldb meetup No.4 meeting minutes
TIPC messaging3
spritejs
一.STM32的开发环境,keil5/MDK5.14安装教程(附下载链接)