Sub SaveInvoiceAsPDF() Dim FileName As String Dim Path As String ' Define where to save (e.g., your Desktop or a specific folder) Path = "C:\Users\YourName\Downloads\" ' Create file name using cell values (e.g., Cell B1 is Invoice #, Cell B2 is Name) FileName = Range("B1").Value & "_" & Range("B2").Value & ".pdf" ' Export the active sheet ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=Path & FileName MsgBox "Invoice Saved to: " & Path & FileName End Sub Use code with caution. Copied to clipboard
Since your file is already an .xlsm (Macro-Enabled), it’s often best to add a button that handles the naming and saving for you automatically. You can use a VBA script to pull the and Customer Name directly from cells to name the file. Sample VBA Code: Download Invoice From xlsm
: For business tax compliance (like GST), you can often download standardized Excel-based invoice formats directly from government GST portals . Pro-Tips for Professionalism: Sub SaveInvoiceAsPDF() Dim FileName As String Dim Path
: Before exporting, highlight your invoice area and go to Page Layout > Print Area > Set Print Area . This prevents extra blank pages or random gridlines from appearing in your download. Sample VBA Code: : For business tax compliance
: Press Ctrl + P , and under the Printer dropdown, select "Microsoft Print to PDF" . This lets you "print" the file directly to your downloads folder as a PDF. 2. The One-Click Way (VBA Automation)