📄 Save Each Mail Merge Entry as a Separate Word File (One-Click Method)

0


📄 Save Each Mail Merge Entry as a Separate Word File (One-Click Method)

If you're working with Mail Merge in MS Word and want to save each entry as a separate Word file, this guide will help you do it easily. I tested multiple methods and finally found one that works perfectly.

🔧 What You Need:

  • Microsoft Word (with Mail Merge setup)
  • Excel file with data (including a column like First_Name)
  • This simple VBA script (shared below)

📝 What This Script Does:

This macro goes through each record in your Mail Merge and:

  • Merges one entry at a time
  • Saves each one as a separate Word document
  • Uses the First Name from your Excel file as the file name
  • Stores all files in: Documents\MergedFiles

No manual work. Just run once — and you're done!

✅ Step-by-Step Guide

1. Open your main Mail Merge document in Word

2. Press ALT + F11 to open the VBA editor

3. Insert a new module and paste the code below:


Sub ExportEachRecordIndividually()
    Dim mainDoc As Document
    Dim singleDoc As Document
    Dim dataPath As String
    Dim i As Integer
    Dim firstName As String

    Set mainDoc = ActiveDocument
    dataPath = Environ("USERPROFILE") & "\Documents\MergedFiles\"

    If Dir(dataPath, vbDirectory) = "" Then MkDir dataPath

    With mainDoc.MailMerge
        If .State <> wdMainAndDataSource Then
            MsgBox "Mail merge is not connected to a data source.", vbCritical
            Exit Sub
        End If

        For i = 1 To .DataSource.RecordCount
            .DataSource.ActiveRecord = i
            firstName = Trim(.DataSource.DataFields("First_Name").Value)

            firstName = Replace(firstName, "\", "")
            firstName = Replace(firstName, "/", "")
            firstName = Replace(firstName, ":", "")
            firstName = Replace(firstName, "*", "")
            firstName = Replace(firstName, "?", "")
            firstName = Replace(firstName, """", "")
            firstName = Replace(firstName, "<", "")
            firstName = Replace(firstName, ">", "")
            firstName = Replace(firstName, "|", "")

            .DataSource.FirstRecord = i
            .DataSource.LastRecord = i
            .Destination = wdSendToNewDocument
            .SuppressBlankLines = True
            .Execute Pause:=False

            Set singleDoc = ActiveDocument
            singleDoc.SaveAs2 FileName:=dataPath & firstName & ".docx", FileFormat:=wdFormatDocumentDefault
            singleDoc.Close False
        Next i
    End With

    MsgBox "All individual documents saved in: " & dataPath
End Sub
            

4. Run the macro (F5)

🎯 Result:

All your Mail Merge entries are now saved automatically as individual Word files named after the First_Name field — no manual saving required.

🙌 Credit:

Thanks to tool creators and communities who contributed their knowledge. This post is just my simplified version so I can refer back to it and help others easily.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.