windows合并多个office
2017-02-15 本文已影响12人
Abler
方法一(看起来高大上)
1. 首先用记事本做一个小程序,以便在文件夹中可以同时选中多个文件。
代码如下:
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 & "篇文档"
将此代码命名为"test.bat"保存。如果没有这个文件,你就不能在插入时同时选定多个要合并的文档