#1
|
|||
|
|||
Multiple page document to individual multiple page documents
Hello MSOffice Forums,
I'm stumped! Is there a way to use a multi-page Word doc to mail merge into many multi-page documents? For example, I have a 5 page document that I want to merge with 50 individual's information (a total of 9 fields per document) to create 50 individual documents of 5 pages each. Thank you so much for helping me get this done and off my mind. It's driving me crazy! Legger |
#2
|
||||
|
||||
Word's built-in mailmerge tools will allow you to create a single document containing all 5 pages for each record. To create a separate file for each record, you'll need a macro.
The following macro generates one output file per record. Files are saved to the same folder as the mailmerge main document, using the ‘Last_Name’ & ‘First_Name’ fields in the data source for the filenames. PDF & DOCX formats are catered for. Code:
Sub Merge_To_Individual_Files() 'Merges one record at a time to the chosen output folder Application.ScreenUpdating = False Dim StrFolder As String, StrName As String, MainDoc As Document, i As Long, j as long Set MainDoc = ActiveDocument With MainDoc StrFolder = .Path & Application.PathSeparator For i = 1 To .MailMerge.DataSource.RecordCount With .MailMerge .Destination = wdSendToNewDocument .SuppressBlankLines = True With .DataSource .FirstRecord = i .LastRecord = i .ActiveRecord = i If Trim(.DataFields("Last_Name")) = "" Then Exit For StrName = .DataFields("Last_Name") & "_" & .DataFields("First_Name") End With .Execute Pause:=False End With StrName = Trim(StrName) With ActiveDocument .SaveAs2 FileName:=StrPath & StrName & ".docx", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False ' and/or: .SaveAs2 FileName:=StrPath & StrName & ".pdf", FileFormat:=wdFormatPDF, AddToRecentFiles:=False .Close SaveChanges:=False End With Next i End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
How to insert macro
Hi Paul,
Thanks for the quick reply. This looks great! Now, I'm going to learn how to record a macro. Cheers Legger |
#4
|
||||
|
||||
Macro recording isn't involved. All you need do is install, edit the ‘Last_Name’ & ‘First_Name’ references, if necessary to match your data, then run it.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Used RD for TOC for multiple docs. Now all show page 1. | Dart82 | Word | 4 | 05-06-2014 11:23 PM |
Multiple records on the same page | Hugh | Mail Merge | 2 | 04-04-2014 05:24 PM |
2 page document printing problem, text from page 1 in layout of page 2 when printed | laurawether45 | Word | 1 | 08-02-2012 07:03 AM |
Consecutive page numbers on multiple documents | georgeeasten | Word | 1 | 02-10-2011 02:12 AM |
page numbering across multiple documents | reitdesign | Word | 3 | 12-12-2008 11:55 AM |