Dim timeStamp As String timeStamp = Format(Now, "yyyymmdd_hhnnss") filePath = "C:\Reports\Report_" & timeStamp & ".pdf" Avoid creating empty PDFs:

'Check if folder exists; if not, create it If Dir(folderPath, vbDirectory) = "" Then MkDir folderPath End If

Sub ExportRangeToPDF() Dim rng As Range Dim filePath As String 'Define the range (e.g., A1:F20) Set rng = ThisWorkbook.Sheets("SalesData").Range("A1:F20") filePath = "C:\PDF Reports\SalesSummary.pdf"

'Export the range rng.ExportAsFixedFormat Type:=xlTypePDF, _ Filename:=filePath, _ Quality:=xlQualityStandard MsgBox "Range exported to PDF." End Sub Hardcoding filenames is useless for automation. Instead, pull data from cells (e.g., invoice number and date).

'Loop through each worksheet For Each ws In ThisWorkbook.Worksheets ws.ExportAsFixedFormat Type:=xlTypePDF, _ Filename:=folderPath & ws.Name & ".pdf", _ Quality:=xlQualityStandard Next ws

Sub SaveEachSheetAsPDF() Dim ws As Worksheet Dim folderPath As String 'Create a folder (adjust as needed) folderPath = "C:\PDF Reports\AllSheets\"

Sub ExportEntireWorkbookToPDF() Dim filePath As String filePath = "C:\PDF Reports\FullWorkbook.pdf"