A complete billing macro: fills the invoice template, exports a client-ready PDF, sends it through late-bound Outlook (no reference required), and appends the record to the Invoice Register with timestamps and totals.
Syntax-highlighted VBA — first 14 lines unlocked. Upgrade to view the full project.
1Option Explicit23' Invoice Generator — build a PDF invoice from the "Invoice" sheet4' and email it to the client using late-bound Outlook.56Public Sub GenerateInvoice()7 Dim ws As Worksheet8 Dim invoiceNo As String, client As String, total As Currency9 Dim pdfPath As String1011 On Error GoTo Fail12 Set ws = ThisWorkbook.Worksheets("Invoice")1314 invoiceNo = NextInvoiceNumber()15 ws.Range("F4").Value = invoiceNo1617 client = CStr(ws.Range("B10").Value)18 total = CCur(ws.Range("G40").Value)1920 pdfPath = ThisWorkbook.Path & "\Invoices\" & invoiceNo & ".pdf"21 EnsureFolder ThisWorkbook.Path & "\Invoices\"2223 ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=pdfPath, _24 Quality:=xlQualityStandard, IncludeDocProperties:=True, _25 IgnorePrintAreas:=False, OpenAfterPublish:=False2627 SendInvoiceEmail client, invoiceNo, total, pdfPath28 LogInvoice invoiceNo, client, total, pdfPath2930 MsgBox "Invoice " & invoiceNo & " emailed to " & client, vbInformation31 Exit Sub32Fail:33 MsgBox "Invoice failed: " & Err.Description, vbCritical34End Sub
Unlock XLFormula AI Pro to view the complete project source, download the .xlsm workbook, and generate custom VBA with AI.
Unlock with ProEvery download, every VBA project, every future release for $5.00/month.
Mail-merge personalised emails with per-row attachments, rate limiting, and delivery logging.
Categorise transactions, roll up totals, and refresh a live budget dashboard with one macro.
Refresh every PivotTable and chart, then export a snapshot PNG for the daily report.