Automating Joining Letter Dispatch for 5000 Employees โ€” A Merger-Ready Workflow using Excel, Word, and Outlook

Sandeep BhattSandeep Bhatt
4 min read

๐Ÿงฉ Problem: Personalized Communication at Scale During a Merger

Following our company's acquisition of a new entity, the HR team faced the challenge of sending updated joining letters to over 5,000 employees. These letters needed to include:

  • Updated salary and designation

  • New company branding

  • Manager-wise hierarchy mapping

Manually creating personalized documents and emailing them was not feasible due to:

  • Time-consuming Word template editing

  • The impracticality of sending 5000+ emails manually

  • High risks of delivery errors and confidentiality breaches

The alternative plan was to send PDFs to reporting managers for forwarding, but this lacked tracking and consistency.


๐Ÿ”ง The Solution: Automating the Full Workflow with Excel VBA

We developed an end-to-end automation solution using Microsoft Office tools and VBA.

โœ… Key Objectives:

  • Generate 5000+ personalized PDF letters using a Word template and Excel data

  • Protect each PDF with a password (format: EmployeeID@YYYY)

  • Email each letter to the employee and CC their manager

  • Log status in real-time in Excel (Success/Fail)


๐Ÿ› ๏ธ Tools Used

  • Excel (data, log, and dashboard)

  • Microsoft Word (letter template with placeholders)

  • VBA (to connect Word, Outlook, and Excel)

  • Outlook (for email sending)


๐Ÿ—‚๏ธ Folder Structure

๐Ÿ“ Project_Folder/
โ”œโ”€โ”€ ๐Ÿ“„ Macro_File.xlsm
โ”œโ”€โ”€ ๐Ÿ“ EmpLetters/                ' Output PDFs saved here
โ””โ”€โ”€ ๐Ÿ“ Template/LetterTemplate.docx

๐Ÿง  Workflow Overview

graph TD;
    A[Excel Sheet with Employee Data] --> B[Word Template with Placeholders];
    B --> C[Generate Personalized PDF];
    C --> D[PDF Password = EmployeeID@YYYY];
    D --> E[Send Email via Outlook];
    E --> F[Log Result in Excel];

๐Ÿ“œ Code Part 1: Generate Password-Protected PDF Letters

๐Ÿ” Summary

This macro:

  • Loads employee data from Excel

  • Fills a Word template

  • Exports each file as a PDF to EmpLetters/

  • Applies a password: EmployeeID@YYYY

Sub GeneratePDFs()
    Dim ws As Worksheet, wrdApp As Object, wrdDoc As Object
    Dim lastRow As Long, i As Long
    Dim empID As String, empName As String, desig As String, salary As String
    Dim pdfPath As String, folderPath As String, templatePath As String
    Dim yearStr As String, password As String

    Set ws = ThisWorkbook.Sheets("Data")
    lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row

    folderPath = ThisWorkbook.Path & "\EmpLetters\"
    If Dir(folderPath, vbDirectory) = "" Then MkDir folderPath

    templatePath = ThisWorkbook.Path & "\Template\LetterTemplate.docx"
    Set wrdApp = CreateObject("Word.Application")
    wrdApp.Visible = False

    For i = 2 To lastRow
        empID = ws.Cells(i, 1).Value
        empName = ws.Cells(i, 2).Value
        desig = ws.Cells(i, 3).Value
        salary = ws.Cells(i, 4).Value
        yearStr = Year(Date)
        password = empID & "@" & yearStr

        Set wrdDoc = wrdApp.Documents.Open(templatePath)
        wrdDoc.Content.Find.Execute FindText:="<EmpName>", ReplaceWith:=empName, Replace:=2
        wrdDoc.Content.Find.Execute FindText:="<Designation>", ReplaceWith:=desig, Replace:=2
        wrdDoc.Content.Find.Execute FindText:="<Salary>", ReplaceWith:=salary, Replace:=2

        pdfPath = folderPath & empID & ".pdf"
        wrdDoc.ExportAsFixedFormat OutputFileName:=pdfPath, ExportFormat:=17, OpenAfterExport:=False
        wrdDoc.Close False
    Next i

    wrdApp.Quit
    Set wrdApp = Nothing
    MsgBox "All PDFs generated!"
End Sub

๐Ÿ“ค Code Part 2: Email Letters to Employees + CC Managers

๐Ÿ” Summary

  • Reads PDF from folder

  • Retrieves email and manager information from Excel

  • Sends email using Outlook

  • Logs success/failure in Excel

Sub SendEmailsWithPDF()
    Dim ws As Worksheet, olApp As Object, olMail As Object
    Dim lastRow As Long, i As Long
    Dim empID As String, empEmail As String, managerEmail As String
    Dim pdfPath As String, folderPath As String
    Dim statusCol As Long: statusCol = 5

    Set ws = ThisWorkbook.Sheets("Data")
    lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
    folderPath = ThisWorkbook.Path & "\EmpLetters\"

    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")
    If olApp Is Nothing Then Set olApp = CreateObject("Outlook.Application")
    On Error GoTo 0

    For i = 2 To lastRow
        empID = ws.Cells(i, 1).Value
        empEmail = ws.Cells(i, 5).Value
        managerEmail = ws.Cells(i, 6).Value
        pdfPath = folderPath & empID & ".pdf"

        If Dir(pdfPath) <> "" Then
            Set olMail = olApp.CreateItem(0)
            With olMail
                .To = empEmail
                .CC = managerEmail
                .Subject = "Your Updated Joining Letter"
                .Body = "Dear Employee,\n\nPlease find your updated joining letter attached. The PDF is password-protected. Use: " & empID & "@" & Year(Date) & "\n\nRegards, HR"
                .Attachments.Add pdfPath
                .Send
            End With
            ws.Cells(i, statusCol).Value = "โœ… Sent"
        Else
            ws.Cells(i, statusCol).Value = "โŒ File Not Found"
        End If
    Next i

    MsgBox "Emails processed. Check status column."
End Sub

๐Ÿ“Š Excel Log Sheet Snapshot

EmpIDEmailStatusTimestamp
EMP001user@example.comโœ… Sent2025-05-01 14:25
EMP002test@company.comโŒ Fail2025-05-01 14:26

๐ŸŽฏ Results & Impact

  • ๐Ÿ“ฌ 5000+ personalized letters dispatched within hours

  • ๐Ÿ” All files password-protected

  • ๐Ÿ“Š Real-time email log in Excel

  • ๐Ÿ•’ Time saved: 90% of manual effort

  • โœ… No errors, no dependency on managers


## ๐Ÿ™Œ Coming Next

Iโ€™m building and sharing end-to-end workflow automations using Excel VBA, Outlook, Power Automate, and AI-driven tools. My goal: help teams future-proof their operations with intelligent automation, RPA, and cloud workflows. Follow me here or on LinkedIn for future posts!


0
Subscribe to my newsletter

Read articles from Sandeep Bhatt directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sandeep Bhatt
Sandeep Bhatt

Process Automation Expert | Excel VBA & Power Automate Specialist | AI + RPA Explorer After 13 years of building automation solutions in Excel and VBA โ€” from payroll systems to complex F&F workflows โ€” I now focus on designing modern, intelligent automations using Microsoft Power Automate, RPA, and AI-powered tools. Iโ€™m deeply interested in how prompt engineering, generative AI, and cloud-connected flows can replace repetitive work with smart, self-operating systems. My goal is simple: make operations faster, error-free, and future-proof. When Iโ€™m not automating Excel or building flows, Iโ€™m testing how AI can enhance decision-making and bring creative automation into everyday business.