Create individual pdf from mail merge

Create individual pdf using mail merge in word from Excel

Copy + Paste below code in word file and Press F5

 

Sub Create_PDF_From_Mail_Merge()
‘This vba code written by Akumar – 99Excel.com

Application.ScreenUpdating = False
Dim DocName As String, PDFPath, Folderpath, From, Till, Message, fs
Folderpath = “C:\99Excel.com – Folder”

Set fs = CreateObject(“Scripting.FileSystemObject”)
If fs.FolderExists(Folderpath) = False Then
fs.createfolder (Folderpath)
Else: End If

From = 1
Till = 5

Message = (Till – From) + 1
While From <= Till

ActiveDocument.MailMerge.DataSource.ActiveRecord = From
DocName = ActiveDocument.Fields(4).Result
PDFPath = Folderpath & “\” & DocName & “.pdf”
Massage = ((Till – From) + 1)

ActiveDocument.ExportAsFixedFormat OutputFileName:=PDFPath, ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
Item:=wdExportDocumentContent, IncludeDocProps:=True

From = From + 1
Wend

MsgBox (Message & ” Pdf Files Saved In = ” & Folderpath)

End Sub