Skip to main content

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 –

Application.ScreenUpdating = False
Dim DocName As String, PDFPath, Folderpath, From, Till, Message, fs
Folderpath = “C:\ – 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

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

End Sub



How to return background color of cell – Vba Code resolved

Copy & paste below VBA code in your Module & use function “=CellColorIndex(A2)” in sheet.


Function CellColorIndex(InRange As Range, Optional OfText As Boolean = False) As Integer
   ‘This Code created by Akumar,
   Application.Volatile True
   If OfText = True Then
   CellColorIndex = InRange(1, 1).Font.ColorIndex
   CellColorIndex = InRange(1, 1).Interior.ColorIndex
   End If
End Function



How Load or unload an Excel add-in program

Click here to visit main page

  1. Click the Microsoft Office Button , and then click Excel Options.
  1. Click the Add-Ins
  1. In the Manage box, click Excel Add-ins, and then click Go.
  1. To load an Excel add-in, do the following:
  2. In the Add-Ins available box, select the check box next to the add-in that you want to load, and then click OK.


To unload an Excel add-in, do the following:

  1. In the Add-Ins available box, clear the check box next to the add-in that you want to unload, and then click OK.