Insert Excel Cell Values into a PDF Email VBA Macro
Question details
Add names or other Excel cell values to the body of an email generated by a VBA macro that creates and attaches a PDF.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user wants to include four signatories stored in worksheet cells in an email sent with a PDF attachment.
- Observed behavior
- The email body should display the cell values on separate lines while the existing macro handles the PDF.
Identify the worksheet and cells containing the names, and find the part of the macro that sets the Outlook email body. The example below assumes the mail item is named mail and the worksheet is named Sheet1.
Append worksheet values to the email body in VBA
Use cell Value properties and line breaks to add the signatories to a plain-text email body.
In Excel, press Alt+F11 to open the VBA editor, then open the module containing your PDF email macro.
After the macro creates its Outlook mail item and before it displays or sends the message, add this code: With mail .Body = .Body & vbCrLf & vbCrLf & "Kind regards," & vbCrLf & _ ThisWorkbook.Worksheets("Sheet1").Range("D2").Value & vbCrLf & _ ThisWorkbook.Worksheets("Sheet1").Range("D3").Value & vbCrLf & _ ThisWorkbook.Worksheets("Sheet1").Range("D4").Value & vbCrLf & _ ThisWorkbook.Worksheets("Sheet1").Range("D5").Value End With
Replace mail with your mail-item variable, Sheet1 with the worksheet name, and D2 through D5 with your signatory cells. Run the macro and preview the message to check the names, line breaks, and PDF attachment before sending.

Work with Excel files and PDFs in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface and support for Microsoft Office formats, making it easier to move existing files. Use WPS Spreadsheets to edit cell values and export a PDF; Excel VBA and Outlook automation may not work the same way in WPS.

Frequently Asked Questions
How do I put each name on a separate line?
In the VBA email Body expression, join each cell's Value with vbCrLf, such as Range("D2").Value & vbCrLf & Range("D3").Value.
How can I use cells from a specific worksheet?
Qualify each range with the workbook and worksheet, for example ThisWorkbook.Worksheets("Sheet1").Range("D2").Value. Replace Sheet1 and D2 with your worksheet and cell.
Does adding cell values create or attach the PDF?
No. The body code only adds text to the email. Retain the existing macro code that creates the PDF and adds it to the mail item's Attachments.
Can I use this code with an HTML email?
The example uses the plain-text Body property. For an HTML message, update HTMLBody instead, use HTML line breaks such as <br>, and escape special characters in the cell values.




