Here's an easy way to merge all the Word documents in a folder into one Word document.
(article continues below)
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
|
This macro should work for Microsoft Word 98, Word 2000, Word 2003, Word 2007 and all popular Microsoft Word versions. Was this macro for merging Word documents helpful? Please let us know.
|
| shm |
8/17/2008 |
I've created the macro as suggested. But I'm not sure what to do next. Is it correct that I put all the .doc files in one folder. Then what do I do next?
|
| Ken Gaebler |
8/18/2008 |
Yes, put all the .doc files in one folder. Make sure you changed the C:\Book\Chapters\ reference to your specific path on your PC.
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!
|
| lizo |
12/12/2008 |
This macro worked perfectly for me! Thanks so much for posting. I just wanted to add a minor note; I believe the files to be merged in the folder are added to the new document in numeric and then alphabetical order, so it's a good idea to rename the files so that they will be in the correct order when the merge occurs.
|
| niats |
1/5/2009 |
thanks so much, worked wonderfully!
|
| buzzermaster |
1/7/2009 |
Isn't this easier? I opened the folder containing all the documents I wanted to merge. I created a blank Word document. Then I dragged the files from the folder and dropped them into the blank Word document, sat back and watched.
|
| Not Quite |
1/15/2009 |
This macro combines the documents, but does not preserve each individual documents headers/footers, page margins, formatting, etc. Thanks anyways.
|
| Yuri |
2/2/2009 |
Awesome. Thanks so much. I was dreading the thought of merge each document one by one... The next thing would be to merge the docs into one and still have the individual ones linked to the master summary doc. That way edits can be done on an individual document level which would be reflected on the Master doc. But hey! I'll take what I can get for now. :-)
|
| CFR |
2/6/2009 |
Thanks for the tip. It worked perfectly.
Comment to Yuri: Using an older Word version (Word 2007 drives me nuts), I used to merge (link) several documents as chapters into one master file. There was a refresh function key you could press to update the master file whenever one of the linked files was edited. Word 2007 doesn't have that Insert File command anymore.
|
| Traian |
2/7/2009 |
Thanks for the macro code. I combined 20 doc files without problem :)
|
| Patrick |
2/22/2009 |
It would be useful to include the entire process for creating this macro from scratch. For those of us who are unfamiliar with the Macro creation process. I tried looking the process up and creating it, but without success.
|
| LG |
2/25/2009 |
Fantastic! I merged over 4,000 documents! Thanks
|
| CN |
3/17/2009 |
Works, but I need to supply the order in which the docs should be merged. I was thinking of putting the doc in excel in the order I want them and then reading the excel doc in macro to supply order of docs. Any ideas how to do that?
|
| Ken Gaebler |
3/17/2009 |
I believe the default behavior for the Microsoft Word merge documents macro is to merge them based on an alphabetical sort of the filenames. So, if you need to supply the order of the docs, your best best may be to rename the docs so they are sequenced alphabetically in the order you want them. That would be easier than writing an Excel macro.
|
| Sam |
3/18/2009 |
Hot damn !! Working like a charm - thanks
|
| Di |
3/25/2009 |
This did not work for me. I even tried the idea from "buzzermaster" but it turn out right. I need something that I can edit.
|
| voross |
3/27/2009 |
Thanks! worked perfectly!
cheers
|
| jon |
4/4/2009 |
I have the same issue as CN. I have about 50 docs and need to select some or all of them in different orders for a new doc. I was thinking of having the list of doc names in excel and then number them in the order I want them then do the merge.
Any thoughts?
|
| Ken Gaebler |
4/4/2009 |
Jon and CN, I threw a quick article together for you. It explains how to rename multiple Word documents at once. Hope that works for you.
|
| kg |
5/4/2009 |
I can try this but I need to take 50 documents and put them together and save them...edit them...and then rebreak them up the way they were originally...with edits included. is that possible?
|
| Dave |
5/5/2009 |
This is great! However, is there a way to make this work where each doc it is taking will start on its own, new page? As a test, I ran this against 7 word docs, and it produced me a 5 page merged doc. Some of my initial docs were only a half page in length, so when combining, it just sort of truncated everything together. Does this question make sense? Thanks.
|
| Ruth M |
5/19/2009 |
This worked great, except that I need to have each .doc on it's own page. What command do I add for the page break between each file?
|
| Cg |
5/29/2009 |
Thanks for this it worked great!
Do you know if there is a way to stitch an Excel document within these as well?
Many thanks!
|
| Mannoh |
6/1/2009 |
Thanks , worked perfectly.
|
| Tz |
6/2/2009 |
Thanks a lot. Unfortunately, it didn't copy the headers and footers, which puts me back to square one. FYI, each of my docs. have different headers and footers.
|
| echen |
6/2/2009 |
how do you alter the micro with an OR statement to take both doc and docx
|
| Christina |
6/11/2009 |
Genius!!! Thanks so much!
|
| Lynton |
6/26/2009 |
Love it! Thanks....
|
| JD |
6/26/2009 |
I entered the macro, ran it, and it produced a blank page. Not sure what to do.
|
| Ken Gaebler |
6/26/2009 |
JD, the macro should work. Doublecheck that you have the right folder path and that you specify .docx or .doc accurately based on your Word docs. Good luck!
|
| Viz |
7/1/2009 |
Can somebody please give me more info about the procedure for implementing a Word macro? I am not so familiar with macros. The only thing I managed to do so far is to open a new empty doc.
Thanks
|
| jdomabyl |
7/28/2009 |
Worked great for me. I used it to combime 577 different html documents into one Word doc.
|
| TT |
7/30/2009 |
That is great!
However, greatly appreciate if any one of you could inform me on how to preserve (after merging the docs) each individual document headers/footers, page margins, formatting, etc.
|
| BD |
8/6/2009 |
This worked great for me.
But I do need to just "merge" all the changes in updates submitted by different people into a baseline document. Can you help me change the macro to do that? I tried to find a function when the macro is in the Developer mode, but couldn't unfortunately. Any extra help will be appreciated!
|
| lwss |
8/13/2009 |
But the Word doc formatting is changed. Is there any line that can be added to the Word macro to keep the Word formatting intact?
|
| Emily |
8/27/2009 |
Hi, I have created the macro, saved it as a submerged file in the foler that contains all of the documents i want to merge and then opened one of the files and run the macro, but nothing happens. Please help.
|
| Ken Gaebler |
8/27/2009 |
Emily, that might happen if the macro is looking to concatenate Microsoft Word .docx docs and your files are actually .doc format Word documents. Make sure you replace .doc in the Macro with .docx or visa versa depending on what type of Word docs you have. Good luck!
|
| dellfalconer |
8/31/2009 |
Worked like a charm in Word 2000. Thanks!
|
| evlindy |
10/6/2009 |
How long should this process take? I created the macro, created a doc in the folder that has the 15 other docs I want to merge, ran the macro, and it seems to be taking quite a long time to process. Does it take some time to complete?
|
| ladybug |
10/6/2009 |
Works perfectly for files stored on a drive!! Is it possible to have this same function work for documents stored within a SharePoint document library?
|
| ell |
10/6/2009 |
I created the macro. I opened up a blank doc in the folder that contained the other docs I want to merge, but is did not work. I have .doc, so it isnt' looking for .docx.
You mentioned changing the path, but I am unsure of what path to use, as it is a folder, within a folder, and several more folders deep. What path is it that I should use?
|
| DB |
10/27/2009 |
You know what would be great... modifying the script to also build a table of contents that indexes the insertion point of each document and uses the document name as the TOC entry. would that be hard to do?
|
If you are an ambitious entrepreneur or an aspiring
executive looking to get involved with a startup, please take the
time to learn more about Gaebler
Ventures.