VBA & Macro Problems

Insert Excel Cell Values into a PDF Email VBA Macro

Adam DavisAdam Davis Nov 13, 2026 870 views

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.

Insert Excel Cell Values into a PDF Email VBA Macro
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the macro

In Excel, press Alt+F11 to open the VBA editor, then open the module containing your PDF email macro.

2
Add the names to the body

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

3
Adjust and test the references

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.

Append worksheet values to the email body in VBA
Plain-text email body: The Body property is for plain text and can affect HTML formatting. If your macro uses HTMLBody, add the values to that HTML instead, using HTML line breaks and escaping special characters. Keep the existing PDF creation and attachment code.
Free Microsoft Office alternative

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.

Edit names and other worksheet values in WPS SpreadsheetsExport spreadsheet content as a PDF for sharingOpen and edit Microsoft Excel XLSX filesUse a familiar interface for a smoother move from Microsoft Office
microsoft office alternative - wps office

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.