当您需要将一个文件夹中的多个文档整合成一个Word文件时,以下方法可以帮助您高效完成任务。
这是最简单直接的方法,适用于文件数量较少的情况。
Word提供“插入文件中的文字”功能,可批量导入多个文档内容。
所有选中的文件内容将按顺序插入当前文档,保留原有格式。
如果您需要频繁执行此操作,可以使用VBA编写脚本自动导入整个文件夹下的所有文档。
Sub InsertFolderContents()
Dim folderPath As String
Dim fileName As String
Dim doc As Document
Set doc = ActiveDocument
folderPath = "C:\YourFolder\" ' 修改为您的文件夹路径
fileName = Dir(folderPath & "*.docx")
Do While fileName <> ""
doc.Range.InsertFile FileName:=folderPath & fileName
doc.Range.InsertBreak Type:=wdPageBreak
fileName = Dir()
Loop
MsgBox "导入完成!"
End Sub
运行宏后,Word会自动导入指定文件夹中所有.docx文件。
本文仅供参考,操作前建议备份原始文件,避免数据丢失。