当前位置:网站首页>Native method merge word
Native method merge word
2022-07-02 11:16:00 【nongcunqq】
import os
# I / O function , Used to get the directory path
import win32com.client as win32
word = win32.gencache.EnsureDispatch('Word.Application')
# start-up word Object application
word.Visible = False # Whether to visualize , If instead True, Will appear frequently on the computer word Document interface
path = r'D:\word'
# File path
files = []
for filename in os.listdir(path):
filename = os.path.join(path,filename)
files.append(filename)
# Get the path of all files in the directory
output = word.Documents.Add()
#print(output)
print(files)
# New empty word file ,
for file in files:
output.Application.Selection.InsertFile(file)
# Splicing documents
doc = output.Range(output.Content.Start, output.Content.End)
# Get the content of the merged document
output.SaveAs('D://word//result.docx') # preservation
output.Close()# close
Reference resources
https://blog.csdn.net/weixin_44999258/article/details/125163277
边栏推荐
- 从ros1到ros2配置的一些东西
- php中self和static在方法中的区别
- 二叉树专题--洛谷 P3884 [JLOI2009]二叉树问题(dfs求二叉树深度 bfs求二叉树宽度 dijkstra求最短路)
- Special topic of binary tree -- acwing 47 Path with a certain value in binary tree (preorder traversal)
- 实验电镜距离测量之Matlab处理
- Use Huawei performance management service to configure the sampling rate on demand
- C# 文件与文件夹操作
- TIPC Cluster5
- 二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)
- Why does LabVIEW lose precision in floating point numbers
猜你喜欢
[applinking practical case] share in app pictures through applinking
Thanos Receiver
Tick Data and Resampling
Implement custom drawer component in quick application
VS2019代码中包含中文内容导致的编译错误和打印输出乱码问题
I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)
Special topic of binary tree -- acwing 47 Path with a certain value in binary tree (preorder traversal)
PHP tea sales and shopping online store
TIPC messaging3
二叉树专题--洛谷 P3884 [JLOI2009]二叉树问题(dfs求二叉树深度 bfs求二叉树宽度 dijkstra求最短路)
随机推荐
[ark UI] implementation of the startup page of harmonios ETS
V2x SIM dataset (Shanghai Jiaotong University & New York University)
Thanos Receiver
解决uniapp列表快速滑动页面数据空白问题
QT learning diary 8 - resource file addition
tqdm的多行显示与单行显示
二.Stm32f407芯片GPIO编程,寄存器操作,库函数操作和位段操作
The first white paper on agile practice in Chinese enterprises was released | complete download is attached
Summary of cases of players' disconnection and reconnection in Huawei online battle service
QT学习日记7——QMainWindow
[AI application] Hikvision ivms-4200 software installation
Flink two Open, implement Batch Lookup join (attached source)
TIPC introduction 1
【云原生】2.5 Kubernetes 核心实战(下)
Jenkins installation
【深入浅出玩转FPGA学习5-----复位设计】
2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises
Rest (XOR) position and thinking
tidb-dm报警DM_sync_process_exists_with_error排查
启牛商学院给的股票账户安全吗?能开户吗?