当前位置:网站首页>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
边栏推荐
- V2x SIM dataset (Shanghai Jiaotong University & New York University)
- The working day of the month is calculated from the 1st day of each month
- V2X-Sim数据集(上海交大&纽约大学)
- TIPC addressing 2
- enumrate的start属性的坑
- Jenkins installation
- Binary tree topic -- p1030 [noip2001 popularization group] find the first order
- ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
- ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
- Logu p3398 hamster looks for sugar (double LCA on the tree to judge whether the two paths in the tree intersect)
猜你喜欢
From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
Special topic of binary tree -- acwing 3540 Binary search tree building (use the board to build a binary search tree and output the pre -, middle -, and post sequence traversal)
One trick to quickly realize custom application titlebar
[play with FPGA learning 5 in simple terms ----- reset design]
The most detailed MySQL installation tutorial
TIPC Service and Topology Tracking4
二叉树专题--AcWing 3540. 二叉搜索树建树(实用板子 构建二叉搜索树 并输出前、中、后序遍历)
PLC-Recorder快速监控多个PLC位的技巧
tidb-dm报警DM_sync_process_exists_with_error排查
【深入浅出玩转FPGA学习3-----基本语法】
随机推荐
[applinking practical case] share in app pictures through applinking
对毕业季即将踏入职场的年轻人的一点建议
SQLite modify column type
Approximate sum count (approximate
八大排序汇总
ros缺少catkin_pkg
Openmldb meetup No.4 meeting minutes
高德根据轨迹画线
Appgallery connect scenario development practice - image storage and sharing
STM32单片机编程学习
tidb-dm报警DM_sync_process_exists_with_error排查
Multi line display and single line display of tqdm
TIPC Cluster5
The most detailed MySQL installation tutorial
[in simple terms, play with FPGA learning 3 ----- basic grammar]
在网上开股票账户安全吗?我是新手,还请指导
Resources读取2d纹理 转换为png格式
TIPC Service and Topology Tracking4
Logu p3398 hamster looks for sugar (double LCA on the tree to judge whether the two paths in the tree intersect)
Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)