Creating a Batch of PDF Files with Excel VBA

Creating a set of batch reports from Excel to PDF is something quite common in the world of reporting.  Automating the task is not.  This article oulines how.  Data integrity and the successful integration of Excel and PDF documents has made the two programs easier to work with in more recent iterations of Excel.  Back in the day it was difficult to get Excel to talk to PDF.  Now it is very simple if you have Adobe PDF and Excel.  
 
I have set up a simple file which creates three PDF files in a batch.  This is simply as a demonstration of how this might work in a larger procedure.  The following is a screen shot of the Excel file.

Printing PDF

The Excel VBA which sits behind the creation of these batch reports is as follows. Be sure to change the file path.

Option Explicit

Sub PDFTest() 'Excel VBA procedure to push data to PDF.
Const str="D:\" 'Change this path to suit
Dim i As Integer

For i=1 To 3
[D7]=i
ActiveSheet.ExportAsFixedFormat xlTypePDF, str & [C9].Value & ".pdf"
Next i
End Sub


The following Excel file show the above VBA procedure as a working example.