当前位置:网站首页>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
边栏推荐
- 八大排序汇总
- C# 文件与文件夹操作
- 二叉树专题--AcWing 1497. 树的遍历(利用后、中序遍历,构建二叉树)
- tidb-dm报警DM_sync_process_exists_with_error排查
- 二叉树专题--AcWing 19. 二叉树的下一个节点(找树中节点的后继)
- Luogu p4281 [ahoi2008] emergency gathering / gathering (tree doubling LCA)
- Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)
- sql left join 主表限制条件写在on后面和写在where后面的区别
- 二叉树专题--AcWing 1589. 构建二叉搜索树
- [quick application] win7 system cannot run and debug projects using Huawei ide
猜你喜欢

MTK full dump grab

Flick two open, realized a batch lookup join (with source code)

TIPC Service and Topology Tracking4

QT learning diary 8 - resource file addition

Thanos Receiver

一.STM32的开发环境,keil5/MDK5.14安装教程(附下载链接)

V2X-Sim数据集(上海交大&纽约大学)

I STM32 development environment, keil5/mdk5.14 installation tutorial (with download link)

Special topic of binary tree -- acwing 18 Rebuild the binary tree (construct the binary tree by traversing the front and middle order)

解决uniapp列表快速滑动页面数据空白问题
随机推荐
C file and folder operation
CentOS8之mysql基本用法
[AGC] build service 3 - authentication service example
Mongodb learning and sorting (condition operator, $type operator, limit() method, skip() method and sort() method)
MTK full dump grab
What are the software product management systems? Inventory of 12 best product management tools
二叉树专题--AcWing 3540. 二叉搜索树建树(实用板子 构建二叉搜索树 并输出前、中、后序遍历)
TIPC Getting Started6
洛谷 P1892 [BOI2003]团伙(并查集变种 反集)
OpenMLDB Meetup No.4 会议纪要
Xiao Sha's pain (double pointer
Special topic of binary tree -- [deep base 16. Example 7] ordinary binary tree (simplified version) (multiset seeks the precursor and subsequent sentry Art)
ctf 记录
一.STM32的开发环境,keil5/MDK5.14安装教程(附下载链接)
Use Huawei performance management service to configure the sampling rate on demand
The difference between self and static in PHP in methods
Supermarket (heap overload
Jenkins installation
sqlite 修改列类型
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘