1. Home
  2. MS Office

Merge Multiple Word 2010 Documents

Unarguably Word 2010 is a best word editor around, apart from providing basic editing tools and charting styles, it also provides an option to customize document in any way you want. Concealed by default, Word 2010 provides an option to add different functions, like for example, by inserting few lines of code you can merge Word documents without having to use any dedicated third party app. In this post we will be inserting few lines of code to merge all contents of documents residing in the same folder and show them in a new one.

To begin, first you need to put them in the same folder, make sure that they all belong to same Word version either Doc or Docx. As you can see in the screenshot below, we have opened two documents that will be merged together.

two documents

Now open any Word document and save it as Macro-Enabled document, for this, go to File menu and click Save As.

save as

A dialog will appear, from Save as type, click Word Macro-Enabled Template and click Save.


We will be using VB editor, so first we need to make Developer tab apparent on Word window. In case you don’t find Developer tab, go to File menu, click Options, and in left pane click Customize Ribbon, from right pane enable Developer check-box. Click OK to to see Developer tab on the ribbon.

developer 1

Now navigate to Developer tab and click Visual Basic.


You will reach VB Editor dialog, from left sidebar double-click ThisDocument to open it’s VB editing window. You will see the code window on the right side. Now put these lines of code in it.

Note: Don’t forget to change the path of the folder where the documents are residing and version of Word documents in these lines of code. To make it easier we have added this precaution in front of the codes as well.

Sub MergeDocs()

Dim rng As Range

Dim MainDoc As Document

Dim strFile As String

Const strFolder = “C:\Users\Usman Javaid\Desktop\Word documents\” ||| (Change the path where your documents are residing)

Set MainDoc = Documents.Add

strFile = Dir$(strFolder & “*.docx”) ||| (Change file extension to .doc incase you are dealing with Word 97-03 version)

Do Until strFile = “”

Set rng = MainDoc.Range

rng.Collapse wdCollapseEnd

rng.InsertFile strFolder & strFile

strFile = Dir$()


End Sub

vb editor

Now press Ctrl+S to save the newly added macro and close the VB editor. Navigate to Developer tab and click Macros.


From the Macros dialog, select MergeDocs macro and click Run.

macros 1

If you have specified path and version correctly, then all documents would merge and open-up in a new document.


You can also check out our previously reviewed guides on Return to last line edited in Word 2010 and using Mail Merge in Word 2010.

[via gaebler]


  1. Ok! This is the first article, that I found about merging files by macros (script). And this method work, but the document structure is crashed during run. When I trying to append the first file with 2 pages document, it appears at new created MSWord window, as 3-4 pages document. What is wrong? How can I make a new document from many identically formatted documents without changing their formatting? Sorry for my poor english…

  2. How do I take this code and just pull out the comments and not the entire document. Any assistance on this will be much appreciated.

    Sub MergeDocs()

    Dim rng As Range

    Dim MainDoc As Document

    Dim strFile As String

    Dim i As Long

    Const strFolder = “C:UserstefeDesktopMerge”

    Set MainDoc = Documents.Add

    strFile = Dir$(strFolder & “*.docx”)

    Do Until strFile = “”

    Set rng = MainDoc.Range

    rng.Collapse wdCollapseEnd

    Selection.InsertBreak Type:=wdPageBreak

    rng.InsertFile strFolder & strFile

    strFile = Dir$()


    End Sub

    It does all that I need, but I don’t need all the other document information other than just the comments from each word document.


  3. Hi,

    I was working on this code. In the file I need to combine multiple word files from a dynamic location (means the location can changed as per the requirement).
    I got a static code, which is working. But i want to convert it to a dynamic code, where i can set the folder location using a folder picker.

    Please help.

    Private Sub Document_New()

    Dim rng As Range
    Dim MainDoc As Document
    Dim strFile As Variant
    Dim strFolder As FileDialog

    Set MainDoc = ActiveDocument
    Set strFolder = Application.FileDialog(msoFileDialogFolderPicker)
    strFolder.AllowMultiSelect = True
    strFile = Dir$(STFolder & “” & “*.docx”)
    Do While strFile “”
    Set rng = MainDoc.Range
    rng.Collapse wdCollapseEnd
    rng.InsertFile STFolder & strFile
    strFile = Dir$()
    End Sub

  4. Yes, I am trying this and it’s not working. My questions are as follows:
    In the Sub MergeDocs() is there supposed to be something added between the parentheses? Also, StrFile=Dir$(strFolder&”.docx”, is “strFolder” supposed to be the name of the folder or is it left “as is”? And Do Until strFile=”” is there supposed to be something between the quote marks? One last, in strFile=Dir$() is there supposed to be something inside these parentheses? Thanks so much.

  5. This is serviously way too complicated for a simple minded, non-technical person like me. Why can’t there just be a simple function with word to combine documents. Following this is likely to get me into serious difficulties.

  6. I need to merge 2 documents into 1 document. The first document is in portrait mode with a header that needs to repeat on each page. The second document is in landscape mode with a header that needs to repeat from page 2 to the last page. Yes, pages 2 on will need to have 2 separate headers. Is this possible to do this in Word?

  7. Is it possible to take two documents and merge them page by page. What I’m trying to say is I want page 1 from document 1 then page 1 from document 2. Then page 2 from document 1 and page 2 from document 2 and so on.

  8. Guys, just dragging the documents from explorer wont let you edit the documents (but if that’s all you’re looking for, then that works) otherwise:

    1.Select the “Insert” tab.

    2.Locate “Object”, press a small triangle next to it, and click “Text from File” from the dropdown menu.

    3.After that, you can select files to be merged into the current document. By pressing and holding Ctrl to select more than one documents.

    (Note: Documents placed at the top will be merged in the first place, so please sort and number each target document in case that you want to keep a certain sequence for your documents. )

  9. All this advice (as well as this article) is horrible. Simply select the documents in Explorer and drag and drop them into a new Word document. It will combine everything without issue.

  10. Wow some people are harsh :-/

    Question: would this work dynamically? I want a merge of say 2 documents whenever I print, for example I have a technical document used for many contexts so don’t wan’t to copy paste every time

  11. Hi, im having a problem, i get this error “Compile error: Invalid or unqualified reference”. I know it is because of the spaces between ” * .docx”, but after i delete the spaces they apear again (after moving the cursor from the area), they wont disappear.
    Also, how do you Change Smart Quotations into Dumb Quotations??, may be this malfunction caused by this?

    Thank you

  12. Why is it soooooooooooo complicated! Why isn’t it just as simple as combining two pdf documents? This is the most frustrating software ever invented.

    • You don’t need to use the macro to merge your files unless they both have headers. If only one doc has a header, and the other is plain text, it can be done without too much trouble. With the header doc open, at the beginning of the document, insert a page break. Then, chose Insert —> Object —> Text from file… Choose the non-header doc and press ENTER to merge them. You might have to tweak the page breaks a little bit, but the pages all the pages should be intact, and exactly as the originals when you’re done. Hope this helped!

  13. this was ridiculously tricky. If you’re using Word 2010, then click on “Insert”, then off to the right you’ll see “Object” – click on that down arrow, choose “Text from File” and then choose the Word files you want to merge together. No VB coding required.

    • That’s not a true merge; it’s just stuffing one file into another. What most people want is to collate comments from multiple reviewers into a single document and have the different author’s comments appear adjacent to each other.

  14. Ridiculously over-complicated. Why is there not a simple, in-built way of doing this? It seems like it should surely be a basic function of Word? How have the software designers overlooked this?
    It’s much quicker and simpler to just copy-and-paste, neolithic as that is.

  15. What if I want to merge two documents that isn’t in the same folder? Is there any way to specify which documents that should be merged? Instead of just merging all .doc in a folder.

  16. IF IT DOESN’T Work. It’s because the quotes around the path aren’t correct in the example.
    “C:UsersUsman JavaidDesktopWord documents” is what he has listed. But look at the FIRST double-quote! It’s a little different than what ou want. Just re-type it and you’re good to go. ““

  17. Can’t you achieve the same result by going to Insert, Text from file (Object), and selecting the files you want to merge?

    • When I have done that I am only able to combine 19 or 20 documents. I have one hundred two page documents I need to combine.

  18. “Unarguably” you are an idiot.  Word 2010 is a huge step back for people that actually work with documents rather than play games.

  19. Hello – I applied your macro and it worked brilliantly. Only problem is, my document now won’t save…. I press save (or save as), it tries for a few seconds then pops back up with the save as window. Any ideas?? I’ve tried a few different formats and different locations and nothing has worked…

  20. Hi, thanks for posting this up. Up until now, I’ve been using the ‘insert text’ button which tends to mess up the formatting.

    This method works great, except for the pages tend to mess up. So I’d get page 10, 11, 12, 13 then 1, 2, 3, 4.

    Does anyone know why? 

  21. Absolutely brilliant!!! I needed to combine 36 word documents into one. This was a HUGE time saver. Thank you, thank you, thank you!!!

  22. Is there anyway to keep the headers of the different documents you are merging as well? This will merge the documents with the correct page breaks and such but it doesn’t allow the different headers throughout the new document. It just keeps the first one. 

  23. the best word editor shouldnt require this convoluted procedure to merge documents! just another proof point that this product totally sux!

  24. What horse shit.  PDF’s drag and drop and you’re done.  This is a fucking nightmare for a simple task.

    • All this advice (as well as this article) is horrible. Simply select the documents in Explorer and drag and drop them into a new Word document. It will combine everything without issue. All this VB nonsense is totally unnecessary.

    • Be thankful someone spent a lot of time to make our life easier. No need for negative comments.

      Are you going to drag and drop hundreds of documents everyday?

  25. Doesn’t work for me.  Throws a syntax error on the “Const strFolder” line no matter what I enter in as the path.  I am no VB expert but have programming experience in VB and C# but can’t figure out why it wants “Expected: line number or label or statement or end of statement”.  FYI, it throws this error at the slash after “C:”.

    • I totally agree. It does EVENTUALLY work once you mess about tweaking this and that, sticking spaces in, page breaks, parentheses, the right kind of quotation marks, etc., etc., but then ONLY if the documents you are merging are straightforward text docs with no headers or footers or anything much else.
      If this is as good as it gets, we’re in real strife!!!

  26. This works! But, I have some questions that will probably expand the code. First, I want a section break between each document that in merged. Pluse I want the page numbering to change based on the section. ie. the first paragraph of each section has a bookmark that is added as a prefix to the page number in the footer.

    • A page brake can be added by inserting this code before line rng.InsertFile as follows:

      Selection.InsertBreak Type:=wdPageBreak rng.InsertFile strFolder & strFile

      …it’s worked for me

  27. thnx this macro worked. I got all the documents merged but the lose the formatting. two different documents are starting from the same page. How to insert page break between separate documents?

  28. Fantastic tips and points!! just had to make slight changes as everyone else seems to have done and all worked 🙂
    Than k you so much!!!


    Currently I have the documents in my library named like the following:

    2011-01-March-Doc 1
    2011-02-March-Doc 2
    2011-03-March-Doc 3

    But they are not being combined in that order… so I don’t know if its alphabetically, but I’m not sure why it’s not sorting correctly when it combines the documents…. any ideas? Or maybe a way that I can specify a sort type in the macro code?

    • I have the same problem, I find that merging >10 doc at a time helps. Of course, its really no help at at when your report runs 100 over pages…

    • Has anyone had success ordering of the combined documents? My files are in the same folder and named–
      Test_C.dox, and

      Here is the order they list in the combined document:

      They don’t match Data modified either.

    • This method has a restrictions on number of opened files (near 115). If You need more, this method not work…

  30. This is working for me, but I’m not sure how to get the documents to add in a specific order. How are they sorting before they are added, and is there a custom way to sort them? Like by filename or something similar?

  31. Im getting a “Object variable or With block variable not set” error. does anyone know how to solve this?

  32. Does anyone have a simple macro that will combine multiple word documents that are open into one document (without saving them)?

    Many thanks!

  33. Thank you. With the help in the comments it eventually worked…but unfortunately lost much of the formatting and combined headers along the way so it didn’t end up being functional for my needs.

  34. Thanks very much, it eventually worked, but I had to read the comments before I could manage. For some strange reason every time I saved my VB work, spaces started to appear in the strFile = Dir$(strFolder & ” * .docx”) part of the code, I first had to reduce it to strFile = Dir$(strFolder & ”*.docx”) before I had success.

  35. This is a great macro, worked when I replaced “ with ”
    I’m merging xml files.

    2 quick questions

    1) How do you add a page break between documents?
    2) Why does it reformat my tables in the documents, so they fall off the page.

    Thank you for any help.

    • Merge with page greak:

      Sub MergeDocs()

      Dim rng As Range

      Dim MainDoc As Document

      Dim strFile As String

      Const strFolder = “H:Dokumentyjuniorstav 2011 1.2”

      Set MainDoc = Documents.Add

      strFile = Dir$(strFolder & “*.doc”)

      Do Until strFile = “”

      Set rng = MainDoc.Range

      rng.Collapse wdCollapseEnd

      Selection.InsertBreak Type:=wdPageBreak

      rng.InsertFile strFolder & strFile

      strFile = Dir$()


      End Sub

  36. Thank you, excellent instructions. Initially, I also had problems similar to those outlined above. However, after changing the smart quotes for dumb quotes AND making sure that there were no additional spaces in this bit: “*.docx” , all worked perfectly well. (This last was important – before that, I got an empty one page document. When I copied the text from the web, in addition to smart quotes, I had blank spaces before and after the * ).

    • I was having similar problems until I read your posting about eliminating spaces. Thank you so much!

    • Thank you for clarifying this. After implementing your suggestions it worked like a charm!

      My path was to
      1. Change Smart Quotations into Dumb Quotations
      2. Eliminating the spaces
      3. Sigh of relief when my 300 documents merged together.

    • Thanks sooo much. I was having the “blank page” problem until I took the spaces off the *.doc section. Cheers!

    •  JennyH, thank you so much for adding the ‘remove spaces’ comment!! (And USMAN–I could KISS YOU FOR THIS!)

    • Appreciate your comment above. Worked OK, but I am merging documents full of labels and when it merges it loses all the formatting. Any ideas how to maintain the formatting of the original documents?

  37. For some reason mine is not working. I am confused as to what I replace this with

    strFile = Dir$(strFolder & ” * .docx”)

    All my files are 2010 so I just deleted the last part. I keep getting “can’t execute code in break mode”?? What does that mean and how do I fix it to merge the documents?

    • Hi Mary, 

      Did you get an answer to this question? I can’t seem to get it to work either. I have exactly the same problem. 



    • Ha, just worked it out… close the Visual Basic program before trying to run the Macro… But now I’m getting a blank document. Will have to keep reading the comments… 

  38. Great starting point!
    I added a macro to globally set the font and size as well as name and save the merged document.

    I’m combining 27 separate documents (chapters) into one document (manuscript) and this makes it easy to edit a chapter and recombine the manuscript.


  39. I also get a syntax error. You need to get rid of everything after the 3 vertical lines i.e.

    Const strFolder = “C:\Users\Usman Javaid\Desktop\Word documents\” ||| (Change the path where your documents are residing)

    should just be

    Const strFolder = “C:\Users\Usman Javaid\Desktop\Word documents\”

    Otherwise you’ll get a syntax error.

  40. Anybody know if there’s a macro that basically lets you combine revisions from several authors into a single document? You can do this with Word’s “combine” function, but it only allows you to combine two documents at a time. I need something that would allow me to combine several documents at once.

  41. What if I wanted to insert a line of text that appears in-between each inserted document, or literally what I am wanting to do is insert the name of document that is currently being merged in, so that it appears at the top of the text of the document currently being merged in?

  42. I eventually got it to work, but a couple things tripped me up and it looks like they tripped other people up from this thread. First, if you copy/paste from the code above, you will have “smart quotes” (the kind that are different for the open quote and the end quote). You need to replace these with “dumb quotes”–the kind that go straight up and down or you will get a syntax error. Second, you have to make sure that you have a “\” at the end of the path, or you will just generate a blank document.

    Thanks for the handy tool!

  43. Hi,

    Thank you for this great article. Only problem is I am getting an compile error for the file path I entered for strFolder.

    Const strFolder = “C:\Users\Usman Javaid\Desktop\Word documents\”

    Expected: Line number lable or statement or end of statement.

    • Hi Morphy,

      You need to change the style of paranthesis. It should work then. Also make sure that you are adding “\” sign at the end of files locaiton.

  44. @joshua the combine feature will only combine TWO docs….

    Thankyou for sharing this wonderful tip..i have just merged 27 documents…looking for this one….

    • Yes you can do that from built-in Combine (Merge) option but it would combine two different versions of document. This post elaborates how to merge multiple documents residing in same folder. All you need to do is place the documents in one folder (which you want to merge), make a macro and it would merge all the documents…

    • If you Could Use Extra payment Averaging 50-300 Bucks every day for doing an online Job on your Computer From home for 3-4 hrs each day then read more Here

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.