# Save individual word merged documents with a specific merged field name....



## andnand (Jun 2, 2008)

[FONT=Verdana, Arial, Helvetica]Hi, I hope someone can help.  

I have a merged word document with more than 200 unique pages created using   data from an excel file. I always have to go one by one printing a pdf. I   
select a specific merged field, CTRL C, CTRL P, printer: pdf, CTRL V for the file name,   mouse click next document, and again....  

Is there a way to make this process easier, automate it.  


Thank you,  

Andrew  [/FONT]


----------



## gwkenny (Jun 2, 2008)

Most certainly, though it would be helpful if you upped a sample main and sample data file (taking out private info).


----------



## andnand (Jun 2, 2008)

I dont have permission to post attachments so here is a linf for the sample files.

The field used to name the files is "DOCUMENT", there are a few pdf within the zip file to show the desired outcome.

Thank you.

ZIP file: http://www.marketabroad.com/WORDMERGEPRINT.zip


----------



## gwkenny (Jun 4, 2008)

Your PDF printer driver:  Is it free?  If so, tell me what it is and I'll download it and I can finish the code.

If it is not free, what is the exact name of the Printer as it appears in the Print dialog box?

After you choose the "pdf" printer, can you immediately hit ctrl-v?  Or do you have to mouse click in the field?


----------



## andnand (Jun 4, 2008)

Printer: "Adobe PDF"


I choose the printer the first time only.

I was trying to use this code but haven't been able to make it work. I haven't been able to figure out how to assign a merge field as the filename.

The 2 problems are the name of the file, and pressing enter after each pdf.

Thank you


[FONT=Verdana, Arial, Helvetica] Sub PRINTPDF()  
'  
' PRINTPDF Macro  
' Macro recorded 6/2/2008 by DELL  
'  
Dim i As Long  
' i = ActiveDocument.MailMerge.DataSource.RecordCount  
i = 5  
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord  

Do While intCounter < i  
intCounter = intCounter + 1  

ActivePrinter = "Adobe PDF"  
Application.PrintOut FileName:="""DOCUMENT""", Range:=wdPrintCurrentPage,   
Item:= _  
        wdPrintDocumentContent, Copies:=1, Pages:="",   
PageType:=wdPrintAllPages, _  
        ManualDuplexPrint:=False, Collate:=True, Background:=True,   
PrintToFile:= _  
        False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _  
        PrintZoomPaperHeight:=0  

ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument  
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord  

Loop  
End Sub


[/FONT]


----------



## gwkenny (Jun 4, 2008)

filename is easy.

In your Main mail merge document, assign a bookmark to the field that will be the filename.  I used a long descriptive name:  ToFileName

The code to access the text in this bookmark would be:

ActiveDocument.Bookmarks("ToFileName").Range.Text

Thus the following in your code:

Application.PrintOut FileName:="""DOCUMENT""", Range:=wdPrintCurrentPage, 
Item:= _ 

Would change to:

Application.PrintOut FileName:=ActiveDocument.Bookmarks("ToFileName").Range.Text
, Range:=wdPrintCurrentPage, 
Item:= _ 

***********

That should take care of the name of the file.

Why do you have to hit Enter after each file?


----------

