View Single Post
 
Old 03-06-2022, 05:35 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you combine all the mailmerge main documents into a single document, with a separate Section for each of your present source documents, you could use the code from the Send Mailmerge Output to Individual Files example in the Mailmerge Tips & Tricks 'Sticky' thread at the top of this forum (https://www.msofficeforums.com/mail-...ps-tricks.html) with the following modifications:
1. Add
, Sctn As Section
to the 'Dim' line at the top of the code

2. Replace:
Code:
        .SaveAs FileName:=StrFolder & StrName & ".docx", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
        ' and/or:
        .SaveAs FileName:=StrFolder & StrName & ".pdf", FileFormat:=wdFormatPDF, AddToRecentFiles:=False
with:
Code:
        For Each Sctn In .Sections
          Sctn.Range.Select
          With Selection
            Do While .Characters.Last = Chr(12)
              .End = .End - 1
            Loop
          End With
          .ExportAsFixedFormat OutputFileName:=StrFolder & StrName & "_" & Sctn.Index & ".pdf", _
            ExportFormat:=wdFormatPDF, OpenAfterExport:=False, _
            OptimiseFor:=wdExportOptimizeForPrint, Range:=wdExportSelection
        Next
With these changes, you will get 20 separate documents for each record in your data source.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote