Merge Word Documents
How to Combine Multiple Word Documents into One Document
Wondering how to combine multiple Word documents into a single Microsoft Word document? Here's a simple way to merge Word documents in a directory.
Here's an easy way to merge all the Word documents in a folder into one Word document.
All you need to do is setup this simple Microsoft Word macro to merge many Word documents into a single Word document.
We are posting it here because it's not easy to find out how to do this. You can search for "Word merge documents in a directory" or "Microsoft Word merge documents macro" and a ton of variants and you might never find it.
So, hopefully you know how to setup a Word macro. Just add this macro for merging Word documents to your list of macros, then open a Word doc in the folder that has all your other Word docs, and run the macro. The macro loops through all the Word docs in the directory and combines them together. Voila! You're done.
Sub MergeDocs() Dim rng As Range Dim MainDoc As Document Dim strFile As String Const strFolder = "C:\Book\Chapters\" 'change to suit Set MainDoc = Documents.Add strFile = Dir$(strFolder & "*.doc") ' can change to .docx Do Until strFile = "" Set rng = MainDoc.Range rng.Collapse wdCollapseEnd rng.InsertFile strFolder & strFile strFile = Dir$() Loop End Sub
Share this article
Additional Resources for Entrepreneurs
Also, you need the backslash at the end.
Now, you can open any Word doc and run the MergeDocs macro. The Macro will create a new Word document and merge the contents of all of the Word documents in the specified folder into that new Word document. Then, save that Word document and you should be good to go. Good luck!
You just need to duplicate the lines for each document that you want to merge. The sequence in which you list them is the sequence in which they appear.
Sub FullBook()
'
' FullBook Macro
'
'
Selection.InsertFile FileName:="Introduction - 03.doc", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdPageBreak
Selection.InsertFile FileName:="Introduction - 04.doc", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdPageBreak
Selection.InsertFile FileName:="Introduction - 05.doc", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.InsertBreak Type:=wdPageBreak
End Sub
Sub MergeDocs()
Dim rng As Range
Dim FinalEvidence As Document
Dim strFile As String
'Dim OutPut_file_name As String
Const strFolder = "C:\Test\" 'change to any dir which you wanna use
Set FinalEvidence = Documents.Add
strFile = Dir$(strFolder & "*.doc")
Do Until strFile = ""
Set rng = FinalEvidence.Range
rng.Collapse wdCollapseEnd
rng.InsertFile strFolder & strFile
strFile = Dir$()
Selection.InsertBreak Type:=wdPageBreak
Loop
' OutPut_file_name = "FinalEvidence.doc"
End Sub
Sub MergeDocs()
Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Const strFolder = "C:\Users\Desktop\Merge"
Set MainDoc = Documents.Add
strFile = Dir$([C:\Users\Desktop\Merge] & ["Doc1*.docx])
Do Until strFile = ""
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
rng.InsertFile strFolder & strFile
strFile = Dir$()
Loop
End Sub
Tks,
Demmy
Sub MergeDocumentsAsImages()
Dim counter As Integer
counter = 0
Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Const strFolder = "C:\Book\Chapters\" 'change to suit
Set MainDoc = Documents.Add
strFile = Dir$(strFolder & "*.docx") ' can change to .docx
Do Until strFile = ""
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
If (counter > 0) Then
Selection.InsertBreak Type:=wdPageBreak
End If
counter = counter + 1
Documents.Open FileName:=strFolder & strFile, ConfirmConversions _
:=False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
Selection.WholeStory
Selection.Copy
ActiveWindow.Close
Selection.PasteSpecial DataType:=wdPasteMetafilePicture
strFile = Dir$()
Loop
End Sub
Sub MergeDocs()
'
' MergeDocs Macro
'
'Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Const strFolder = "F:\new\" 'change to suit
Set MainDoc = Documents.Add
strFile = Dir$(strFolder & "chapters.docx") ' can change to .docx
Do Until strFile = ""
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
rng.InsertFile strFolder & strFile
strFile = Dir$()
Loop
End Sub