I have the following Code that generates separate PDF Files for each rows of my excel sheet.
My goal is to generate a Single PDF file having a number of pages instead of seperate PDF Files.
Can any kind soul help me with this?
Option Explicit
Sub Create_PDF_Files()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim dsh As Worksheet
Dim tsh As Worksheet
Dim setting_Sh As Worksheet
Set dsh = ThisWorkbook.Sheets("Data")
Set tsh = ThisWorkbook.Sheets("Letter Template")
Set setting_Sh = ThisWorkbook.Sheets("Settings")
Application.DisplayStatusBar = True
Application.StatusBar = ""
Dim i As Integer
Dim File_Name As String
For i = 2 To dsh.Range("A" & Application.Rows.Count).End(xlUp).Row
Application.StatusBar = i - 1 & "/" & dsh.Range("A" & Application.Rows.Count).End(xlUp).Row - 1
tsh.Range("C2").Value = dsh.Range("A" & i).Value
tsh.Range("C3").Value = dsh.Range("D" & i).Value
tsh.Range("C5").Value = dsh.Range("E" & i).Value
tsh.Range("C6").Value = dsh.Range("F" & i).Value
tsh.Range("C7").Value = dsh.Range("G" & i).Value
tsh.Range("C8").Value = dsh.Range("H" & i).Value
tsh.Range("C9").Value = dsh.Range("I" & i).Value
tsh.Range("C10").Value = dsh.Range("J" & i).Value
tsh.Range("D12").Value = dsh.Range("K" & i).Value
File_Name = dsh.Range("B" & i).Value & "_" & dsh.Range("C" & i).Value & "_" & dsh.Range("K" & i).Value & ".pdf"
tsh.ExportAsFixedFormat xlTypePDF, ThisWorkbook.Sheets("Settings").Range("F4").Value & "\" & File_Name
Next i
Application.StatusBar = ""
MsgBox "PDF files generated successfully."
End Sub