Attaching pdf in mail merge
The joys of mail merge!
To attach a PDF file in a mail merge, you'll need to use a combination of Microsoft Word, Adobe Acrobat, and some clever formatting. Here's a step-by-step guide to help you achieve this:
Prerequisites:
- Microsoft Word 2010 or later version
- Adobe Acrobat DC or later version
- A PDF file you want to attach
Step 1: Prepare your PDF file
- Open your PDF file in Adobe Acrobat DC.
- Go to File > Save As and choose PDF as the file type.
- In the Save As PDF dialog box, select Attachments as the Save as type.
- Click Save to save the PDF file with attachments.
Step 2: Create a mail merge document in Microsoft Word
- Open Microsoft Word and create a new document or open an existing one.
- Go to Mailings > Start Mail Merge > Step-by-Step Mail Merge Wizard.
- Follow the wizard to set up your mail merge, including selecting a data source (e.g., an Excel spreadsheet).
Step 3: Insert the PDF file using a merge field
- In your Word document, place your cursor where you want to insert the PDF file.
- Go to Insert > Quick Parts > Field.
- In the Field dialog box, select Merge Field from the Categories list.
- Choose a merge field that corresponds to the data you want to use to attach the PDF file (e.g., a customer ID).
- Click OK to insert the merge field.
Step 4: Use a VBA script to attach the PDF file
- Open the Visual Basic Editor by pressing Alt + F11 or by navigating to Developer > Visual Basic.
- In the Visual Basic Editor, create a new module by clicking Insert > Module.
- Paste the following VBA script:
Sub AttachPDF() Dim doc As Document Set doc = ActiveDocument Dim mergeField As MergeField Set mergeField = doc.Fields.Item("YourMergeField") Dim pdfPath As String pdfPath = "C:\Path\To\Your\PdfFile.pdf" ' Update this path with your PDF file location Dim attachment As Attachment Set attachment = doc.Attachments.Add(pdfPath) attachment.FileName = mergeField.Result End Sub
Replace "YourMergeField" with the actual name of your merge field, and update the
pdfPath
variable with the location of your PDF file.
Step 5: Run the VBA script
- Close the Visual Basic Editor and return to your Word document.
- Go to Mailings > Finish & Merge > Edit Individual Documents.
- In the Edit Individual Documents dialog box, select Edit.
- Click Run to run the VBA script, which will attach the PDF file to each document based on the merge field values.
That's it! Your mail merge document should now include the attached PDF file.