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

andnand

Board Regular
Joined
Apr 18, 2008
Messages
53
Office Version
  1. 365
Platform
  1. Windows
[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]
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Most certainly, though it would be helpful if you upped a sample main and sample data file (taking out private info).
 
Upvote 0
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?

:)
 
Upvote 0
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]
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,426
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top