New Documents From Mail Merge

I've run a mail merge and have 8,000 single page documents seperated by a "Section Break"  When I use the code below to save them as individual files I get the "Section Break" on all 8000 documents which adds a second page to the document.  

I need to know how to make it so I have 8000 single page documents and not 8000 2 page docs.

Thanks.
 
Sub AllSectionsToSubDoc()
     
    Dim x               As Long
    Dim Sections        As Long
    Dim Doc             As Document
    Dim FileName        As String
     
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
     
    Set Doc = ActiveDocument
    Sections = Doc.Sections.Count
    For x = Sections - 1 To 1 Step -1
        Doc.Sections(x).Range.Copy
       
        FileName = Right$("00000000" + x, 8)
       
        Documents.Add
        ActiveDocument.Range.Paste
        ActiveDocument.SaveAs ("D:\WorkInProgress\BOW\WordMod_2\Output\" & FileName & ".doc")
        ActiveDocument.Close False
    Next x
     
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
     
End Sub
WhahAsked:
Who is Participating?
 
GrahamSkanRetiredCommented:
Just use an intermediate Range Object and reduce its length by one character.

Sub AllSectionsToSubDoc()
     
    Dim x               As Long
    Dim Sections        As Long
    Dim Doc             As Document
    Dim FileName        As String
    Dim rng             As Range
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
     
    Set Doc = ActiveDocument
    Sections = Doc.Sections.Count
    For x = Sections - 1 To 1 Step -1
        Set rng = Doc.Sections(x).Range
        rng.MoveEnd wdCharacter, -1
        rng.Copy
       
        FileName = Right$("00000000" + x, 8)
       
        Documents.Add
        ActiveDocument.Range.Paste
        ActiveDocument.SaveAs ("D:\WorkInProgress\BOW\WordMod_2\Output\" & FileName & ".doc")
        ActiveDocument.Close False
    Next x
     
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
     
End Sub
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Remove the section break from the primary merge document if you have one.

Reduce the margins or the font size.

When you merge, the information merged may push the document to two pages.  You need to consider this - perhaps if you do a merge preview it will show you if the document is pushed to two pages.
0
 
WhahAuthor Commented:
If I remove the section break the split and save doesn't work.  

The merge doesn't create two pages but the split is there.  When I run the code to create the individual documents the break is still there and that creates the second page.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.