Word.Tips.Net WordTips (Menu Interface)

Merging to Individual Files

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

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 an older version of Word, will work just fine in 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.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1538) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Merging to Individual Files.

Related Tips:

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!


Comments for this tip:

Angela    22 Jan 2015, 12:32
THIS WAS THE BEST TIP EVER!! Ok, a little over the top but you get the meaning! Thanks.
Anne    16 Jan 2015, 12:29
Thanks! Saved me for a lot of work!
Joyce    14 Jan 2015, 13:32
This is SO helpful, thanks so much. It worked for me on Word for Mac 2011 by the way. It took me a while to figure out how to do "PasteandFormat" -- I should have read the comments first! Thanks to David Smith for the suggestion and code for naming by the first line of the form.
Grateful    11 Jan 2015, 15:26
Dude - You are AWESOME! Thanks!!
David Smith    12 Dec 2014, 16:24
Here is my code. I added a folder picker at the beginning, did PasteAndFormat and removed the hard coded name (so it takes the name of each file from the first line of the form.

Sub BreakOnSection()
    ' Select a folder
    Dim strFolder As String
    Set fd = Application.FileDialog(msoFileDialogFolderPicker)
    With fd
      .Title = "Select the folder into which the documents will be saved."
      If .Show = -1 Then
           strFolder = .SelectedItems(1) & "\"
           MsgBox "The documents will be saved in the default document file location."
           strFolder = "c:\"
       End If
    End With
    ChangeFileOpenDirectory strFolder
    '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.
        Selection.PasteAndFormat (wdFormatOriginalFormatting)

        '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

        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
ali    28 Nov 2014, 07:25
This has saved my bacon today -thank you for posting. Did as others suggested and changed the file location.
Joni    25 Nov 2014, 18:03
When I use this, it changes the format of my letter (eg: it changes the font size, font etc.). How do I keep it so the font is the same as my original document so I won't have to format everything?
Mir    11 Nov 2014, 14:26
Can anybody walk me step by step on how to create and run this macro? I have tried different things, but when I hit "Run" my word document closes and I get no results. This is the first time I try macros. So, I'm a complete newbie. Thanks.
Julian Mackenzie    23 Jul 2014, 16:00
I ran the macro a first time and it worked very well indeed. On my second attempt it would only save the first page of a 2 page document and I cannot work out why. Any suggestions would be welcome.
F. Zohra    08 Jun 2014, 08:55
Very useful tips.
To do mail merge I use data saved in excel,is there a way to force the code to save the file using one of excel field. e.g. save as order # (order # is not in series)which is in my excel column after merging the files and spliting it. please help
Barjesh Syal    20 May 2014, 10:00
Very nice code... Its great...
Loren    19 May 2014, 13:16
OK, I figured out how to paste it with original formatting: instead of Selection.Paste, use Selection.PasteAndFormat(wdFormatOriginalFormatting).

But it is still pasting the section break, or something, so each document has an extra empty page at the end.
Loren    19 May 2014, 13:06
Thanks. This works great, except that VBA ignores my line spacing when it pastes, so the formatting is messed up. When cutting and pasting using the mouse, the spacing is not messed up. Do you know a simple way of modifying this code so that it will preserve things like line spacing? Thanks again.
Lisa Hochhauser    30 Apr 2014, 13:06
Thanks for this macro. Saved me a lot of time!

Two suggested upgrades to this script would be to

1. Let you save it in the location you started from rather than the C drive.

2. Use the first few words of the file to name it (ala word's saving method)

Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 4+5 (To prevent automated submissions and spam.)
          Commenting Terms

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2013)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2013)

Our Products

Premium Newsletters

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2015 Sharon Parq Associates, Inc.