hello-python2020
import win32com.client as win32
import os
word = win32.gencache.EnsureDispatch(\'Word.Application\')

# 启动word对象应用
word.Visible = False
path = \'D:\\program\\disk\\day\\word\\\'

files = []
for filename in os.listdir(path):
    filename = os.path.join(path, filename)
    files.append(filename)
print(files)
# 新建合并后的文档
output = word.Documents.Add()
for file in files:
    output.Application.Selection.InsertFile(file)   # 拼接文档
# 获取合并后文档的内容
doc = output.Range(output.Content.Start, output.Content.End)
output.SaveAs(\'D:\\program\\disk\\day\\test.docx\')     # 保存
output.Close()

  

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-05-11
  • 2021-12-02
  • 2021-11-18
猜你喜欢
  • 2021-07-17
  • 2021-10-09
  • 2021-12-30
  • 2021-10-06
  • 2022-12-23
  • 2021-04-04
  • 2021-10-20
相关资源
相似解决方案