Excel to PDF Automation in 1 Click

Excel to PDF Automation in 1 Click

Creating invoices manually every time can be tiring and repetitive, especially if you deal with multiple clients or data sets. That’s why we created a simple Excel automation that lets you generate professional PDF invoices directly from your Excel file using just one click. No external software, no Outlook, and no complicated tools — just Excel and a bit of smart VBA.

Here’s how it works. We started with a clean Excel sheet that contains invoice data like client name, product details, pricing, and total amount. Once your data is ready, we run a small macro (VBA code) that does all the heavy lifting. It automatically formats the sheet and exports it as a PDF file in a pre-selected folder on your computer. This means you don’t need to copy and paste into Word or manually save each file — the system takes care of it for you.

The best part is that you can use the same Excel file over and over again. Just update the values for each new client or order, click a button, and your invoice is ready. If you have 10 invoices to send, simply repeat the process for each row. This is especially useful for freelancers, trainers, small businesses, and finance teams who need quick, accurate reporting.

We’ve also made a short YouTube video showing exactly how this works — it walks you through the setup in under 3 minutes. Plus, the file is available to download if you’d like to try it yourself. You don’t need to be a coder or Excel expert — it’s beginner-friendly and easy to customize.

Download code here --> https://github.com/DiscoverTalent  

How to Add VBA Code in Excel

  1. Open your Excel file where you want to add the code.
  2. Press ALT + F11 to open the Visual Basic for Applications (VBA) Editor.
  3. In the VBA Editor, find your workbook in the left "Project" window.
  4. Insert a new module (recommended for general-purpose macros):
    • Right-click your workbook (e.g., VBAProject (YourWorkbookName.xlsm)).
    • Choose Insert > Module.
    • A new "Module1" will appear under "Modules".
  5. Copy and paste your code into the module window:
    VBA
    Sub ExportRowToPDF()
        Dim wsSource As Worksheet, wsTemp As Worksheet
        Dim i As Long, lastRow As Long
        Dim pdfName As String, path As String
    
        Set wsSource = ThisWorkbook.Sheets("Sheet1")
        If wsSource Is Nothing Then MsgBox "Sheet1 not found": Exit Sub
    
        Application.ScreenUpdating = False
    
        path = ThisWorkbook.Path & "\"
        lastRow = wsSource.Cells(wsSource.Rows.Count, "A").End(xlUp).Row
    
        For i = 2 To lastRow
            ' Create temp sheet
            Set wsTemp = ThisWorkbook.Sheets.Add(After:=wsSource)
            wsTemp.Name = "Temp_" & i
    
            ' Copy headers and data row
            wsSource.Range("A1:F1").Copy Destination:=wsTemp.Range("A1")
            wsSource.Range("A" & i & ":F" & i).Copy Destination:=wsTemp.Range("A2")
    
            ' Save as PDF
            pdfName = path & "Report_" & wsSource.Cells(i, 1).Value & ".pdf"
            wsTemp.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdfName, IgnorePrintAreas:=False
    
            ' Delete temp sheet
            Application.DisplayAlerts = False
            wsTemp.Delete
            Application.DisplayAlerts = True
        Next i
    
        Application.ScreenUpdating = True
        MsgBox "All PDFs exported successfully!", vbInformation
    End Sub
    
  6. Save your VBA project and return to Excel.
  7. You can now run ExportRowToPDF from the Macros dialog (ALT + F8), or assign it to a button.

This is just the beginning. Excel is powerful when you know how to use it smartly. Whether you’re making reports, invoices, or data summaries, small automations like this save time and avoid errors.

Feel free to try it, share it with your team, and if you like these tips, check out our YouTube channel for more Excel hacks every week.

Thanks for reading — happy automating!

Comments