- Sub MergeDocuments()
- Application.ScreenUpdating = False
- MyPath = ActiveDocument.Path
- MyName = Dir(MyPath & "" & "*.*")
- pagenum = 1
- Do While MyName <> ""
- If MyName <> ActiveDocument.Name Then
- Set wb = Documents.Open(MyPath & "" & MyName)
- Selection.WholeStory
- Selection.Copy
- Windows(1).Activate
- Selection.Paste
- wb.Close False
- Selection.EndKey Unit:=wdLine
- Selection.InsertBreak Type:=wdPageBreak
- pagenum = Word.ActiveDocument.Range.Information(wdNumberOfPagesInDocument)
- Selection.GoTo wdGoToPage, , pagenum
- End If
- MyName = Dir
- DoEvents
- Loop
- Application.ScreenUpdating = TrueEnd Sub
复制代码 |