代码如下:
Dim fs As FileSearch, i As Long, n As Long
Set fs = Application.FileSearch
ml = ActiveDocument.Path
bwj = ActiveDocument.Name
Documents.Add
With fs
.NewSearch
.LookIn = ml
.FileType = msoFileTypeWordDocuments
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
If .FoundFiles.Item(i) <> ml & "\" & bwj Then
Selection.InsertFile FileName:=.FoundFiles.Item(i)
Selection.InsertBreak Type:=wdPageBreak
n = n + 1
End If
Next
End If
End With
MsgBox "共合并了" & n & "篇文档"