![]() |
|
#1
|
|||
|
|||
![]()
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 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. Last edited by macropod; 05-13-2013 at 04:05 PM. Reason: Split from old thread & added code tags & formatting |
#2
|
||||
|
||||
![]()
Hi DaddyMac,
The problem with trying to work from mailmerge previews is that, once you get beyond outputting fields that don't require any in-document processing, the preview cannot be relied on to generate the same output as finishing the merge. For a comprehensive solution, see: http://www.gmayor.com/individual_merge_letters.htm
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Thanks so much for the reply and my apologies for not following up sooner (was down and out for a couple weeks due to illness).
I will study the link you shared - it appears that his download would most likely work but, given my hardheadedness, I may study some of the code he includes on the page to see if I can learn as well. Since my previous post I changed my data source from Outlook to Excel and have a formula in Excel which generates a unique filename, which I in turn include as a mergefield in my Word doc. I'm playing around with having that field in the footer and trying to see if I can split the merged document into separate documents using the footer as a trigger, then saving each one with the merged field text in the footer as the filename. Appreciate the guidance!! |
#4
|
||||
|
||||
![]()
For what you're trying to do with the footers, I don't think the addin will work. I haven't tried it, but that's not how I believe it's designed to work. In that case, you'd need to work with one of the other macros. If you contact the owner of that site, he may be able to help you - I'm not able to do so as I'll be away with only limited internet access over the coming months.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Many thanks! Coincidentally I just finished reading a post of yours over at ExcelForum.
I'm hoping to use the concept of the "Splitter" macro to split pages based on the unique value in either the footer of each page or, e.g., a table cell (where I had it previously), and then save each new document based on that value using a variation of the code in my first post. I'm certain it's easier said than done... |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Individual numbers for pages | ewintrs | Word | 1 | 03-16-2013 12:46 PM |
Merge Word documents using a mailmerge field | Concertina | Mail Merge | 3 | 02-18-2013 04:12 AM |
![]() |
Baldeagle | Mail Merge | 8 | 02-11-2013 04:40 AM |
Individual Pop Up Alerts | vbmike73 | Outlook | 0 | 10-18-2012 06:33 AM |
![]() |
Baldeagle | Mail Merge | 13 | 05-29-2012 02:04 PM |