Hello!
I created a brief script which allows me to save the preview results of single mail merge record (Word 2010) directly to .pdf without having to complete the actual merge to a new file. It uses a filename based on a bookmark ("UniqueName") of several merge fields. This allows me to save the result with a filename from the results of the merge fields (note: I must toggle to preview results prior to executing the macro or I'll just wind up with a filename based on the merge field names, not the results).
Since bookmarks don't "survive" the merge process, I'm wondering whether I can accomplish the same thing for multiple records...? Would it be possible to do a variation of Socrates01's code to have it cycle through each mail merge preview record and save it as a .pdf? So, if I had 5 or 500 mail merge preview records, could I fire a macro that would peel them all off individually and save them each to a .pdf, each with their unique filename from the preview results?
Here is what I use to do this with one record at a time*:
Code:
Sub PREVIEW2PDFfromBookmark()
Dim UniqueFileName As String
UniqueFileName = ActiveDocument.Bookmarks("UniqueName").Range.Text
ActiveDocument.SaveAs2 FileName:="S:\FOLDER\" & UniqueFileName & ".pdf", FileFormat:=wdFormatPDF
End Sub
Any advice or guidance will be greatly appreciated!
Thanks!
*oddly, this macro won't run from my custom ribbon button; I have to select the macro via the Developer tab to get the macro to execute and save the file.