Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Merging to Individual Files.

Merging to Individual Files

Written by Allen Wyatt (last updated August 25, 2021)
This tip applies to Word 2007, 2010, and 2013


When you use the mail-merge feature in Word, you have the option of either printing your results directly or creating a new document. If you choose the latter option, the resulting document contains all the information that normally would have gone to the printer. For instance, if your merge document is a two-page letter, each letter in the resulting document is separated by a section break. Thus, if you are merging the two-page letter with 150 different addresses, then you would end up with a 300-page document with 150 section breaks (one every two pages).

For some people, it would be more helpful if you could merge to individual files. For instance, given the above example you might want 150 individual document files, each two pages long. Unfortunately, that is not one of the options available when using Word's mail-merge feature. The only answer to accomplishing this task is to create a macro that will, based on the merged document (the 300-page one mentioned above) take each section and save it to its own document file.

If you look in Microsoft's Knowledge Base, you will find that there is an old article that deals with this very issue:

The macro presented in the article, even though it was written for Word 97, will work just fine in Word 2007 and later versions. It allows you to separate a merged document into individual files, based on the section breaks:

Sub BreakOnSection()
    'Used to set criteria for moving through the document by section.
    Application.Browser.Target = wdBrowseSection

    'A mailmerge document ends with a section break next page.
    'Subtracting one from the section count stop error message.
    For i = 1 To ((ActiveDocument.Sections.Count) - 1)

        'Select and copy the section text to the clipboard

        'Create a new document to paste text from clipboard.

        'Removes the break that is copied at the end of the section, if any.
        Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
        Selection.Delete Unit:=wdCharacter, Count:=1

        ChangeFileOpenDirectory "C:\"
        DocNum = DocNum + 1
        ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
        'Move the selection to the next section in the document
    Next i
    ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub

It is important to realize, however, that this macro will only work if the only place that section breaks occur is between merged documents. If your original document includes section breaks, then the macro will not provide satisfactory results. For additional information on using the macro, refer to the Knowledge Base article at the link provided above.


If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (8435) applies to Microsoft Word 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Word here: Merging to Individual Files.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Finding the First Non-Digit in a Text Value

If you have a string of text that is composed of digits and non-digits, you may want to know where the digits stop and ...

Discover More

Selecting a Cell in the Current Row

Macros often need to select different cells in a worksheet. Here's how you can use macro commands to change which cell is ...

Discover More

Transposing Two Words

A common editing task is to transpose two adjacent words, so that their order is changed. While the task is common, there ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Conditional Processing During a Mail Merge

The Mail Merge capabilities built into Word can appear limited at first glance. One thing that is often overlooked (and ...

Discover More

Selecting Different Trays in a Mail Merge

When you create a mail-merged document, you might want some pages of the document printed on paper from one printer tray ...

Discover More

Conditionally Adding a Period in a Mail Merge

When merging data into a Word document, you may want to add information to the document based on an evaluation of what is ...

Discover More

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is five more than 6?

2021-08-26 09:43:26


Well, there's always the WayBack machine:*/

2021-08-25 08:32:32


As of 2021, the Microsoft Knowledge Base link is no longer valid.

2020-10-29 03:01:33

Victor Ordu

Thanks for this article, it was very useful. I was able to create the files with this macro. However, the formatting and page settings (e.g. margins were distorted and so I can't use them. How can I set the output in such a way that the resulting documents look exactly like the source document? I'm using Office 365.

2018-03-15 05:36:59


ignore, I found that.

2018-03-15 05:01:27


My merged doc was in Lanscape orientation, after running those scirpts and all exported files becomes a portrait one?

Is there any way to maintain it's orientation?

2018-01-04 14:16:45


Instead of this:
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"

This will work better:
ActiveDocument.SaveAs FileName:="test_" & i & ".doc"

Because if you run the same twice, the DocNum will be greater. If you use "i" then it will match the document section.

2017-07-31 12:04:35


Could you add to this how to create the macro using the text above? How would I record this?


2017-01-18 14:58:43


How do you execute this code? I'm familiar with excel VBA but there is no option to 'run' in Word.

I'm also trying to run this in Word 2013 (not sure if it matters).

Thank you in advance!!

2016-12-06 17:01:30


This works great.. however, how do we pull the header too?

2016-09-12 15:09:00

Simon Odell


This Macro works great however I lose all formatting once running it.

It turns most of the font bold and then adds loads of extra spaces between paragraphs.

Is anyone aware of a solution to this?


2016-08-18 10:38:38


Great stuff. Easy, quick and effective. I'm not going to bother trying to name each letter based on something within the letter. numbering them will do fine.


2016-03-05 07:14:57


I used this macro just the other day and it worked fantastically. It saved me a bunch of time.

I only ran into 1 issue: where I had arranged a list into columns on the master merged document prior to splitting, I guess Word looks at columns as sections, and it actually split the second column into a separate file so I had to copy the info back into the file in which it belonged. I would therefore suggest you make those kinds of modifications after you split the file.

The main thing I noticed is that the extension now needs to read docx since it saved everything out to .doc it looked like older versions. It was no big deal for me, but when I put them on SharePoint, which is what I needed them for, the users had to convert the files, which was a little weird. So I changed it.

I saved the macro into my normal.dotx file so that I can use it in the future.

To answer some of the questions on this post: you just run the mail merge as normal. Then you run the macro.

2016-01-20 04:18:13


I do not really use macros usually, thus this question might seem silly, but is there a way to set one of the merged details - such as a project number - as the name of the individual file created?
E.g. I have projects 123, 124, 130 etc. and after the merge I get 123.doc, 124.doc, 130.doc..

2015-08-05 05:32:46


Hello everyone,
I am trying to run this Macro, but there is an error coming up with 5156 number. It is in the line towards the end
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"

I am using word 2010. Any help will be hugely appreciated!
Many thanks

2015-07-23 09:20:58

Garyu Novak

How do we get DaveV's macro? This is exactly what I am looking for

2015-06-02 10:20:18


I am really not able to run this macro.. do we have to add separate code for mail merge?, becoz everytime i run this, it only gives 1 file as an output, which is the 1st record of the XL file.

Steps I am doing:
- Merge the doc with XL file fields
- Create the fields in doc and dry run to check the data is coming fine
- add the section page break
- copy the code in VB editor and save file as .docm
- then select the data in document and run the macro..

VOLA - only 1 page comes out as an output

2015-05-07 12:06:05


Is there anyway I can run this without individual documents opening? I've got 2000 that I really don't want popping open on my pc.

2014-10-28 22:31:29


The above macro is great, I would like to add a piece of code that applies a file name to each file rather than a #. Ideally this would be pulled from the merged letter, so that I can relate each letter to a person by the file name. Does anyone have any ideas?

2014-10-15 16:00:51

B. Urick

Thanks for this posting. I ran into an issue where I wanted to create 100+ individual merged documents then print them consecutively with staples.

The max number of documents that can be selected in Windows 7 is 15, so this was going to be a pain to select 15, print, repeat.

Add a print command into the macro.

This may seem obvious to experienced users, but this I am just starting.

Here is my modification:

ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"

Worked great. It uses the default printing settings, just like batch printing from the menu.

2014-09-08 02:04:27


I had been trying all sorts of macros until i tried this one and I must say it was AMAZING! This is the BEST macro ever. Splits files into individual files with such less effort. Thank you so much!

2014-08-24 00:13:30


Have you looked at Graham Mayor's pages for splitting merged document to individual documents?

2014-06-04 15:41:29


I'd like to get detail from DaveV each resulting with naming convention from mail merged document?

2014-02-18 09:14:47


DaveV, I beg you! Can you possibly share what you wrote for this? It's exactly what I need to do. I am so new at this that it's driving me nuts!

2013-09-05 09:46:27


This solution from MS did not help me. Instead I ended up creating a process/macro where I setup the mail merge as normal (manual process) but then run a macro that does the actual merge generation process. It runs the mail merge process for one record at a time and saves each resulting file with the naming convention that I want (using info from the mail merge document). In this same saving process I am also able to create PDFs. Wish MS would put this type of option on the knowledge base.

2013-08-14 15:52:54

J. Mason


I'm a newbie. How do you use the macro? Do you create the mail merge and then run the macro? Do you create the mail merge any differently than usual?


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.


FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.