把代码所在的文件也放到需要合并的文件中 ,所有需要合并的文件都放在这个文件夹中。 每插入一篇文章后,再插入一个人工分页符,以区别不同的文章。 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 & "篇文档"
[此贴子已经被作者于2008-4-21 22:29:12编辑过] |