Attachment Issues

How to Attach Embedded Excel Files to Outlook Email with VBA

Phi Hung VoPhi Hung Vo Nov 13, 2026 869 views

Question details

The user wants to attach files that are embedded in an Excel worksheet to an Outlook email through VBA, but Outlook cannot use embedded OLE objects or displayed cell values directly; each attachment must be a valid file path or a temporary exported file.

Product
Microsoft Excel and Microsoft Outlook
Device & OS
not provided
Scenario
A user is automating email attachments from an Excel workbook with VBA and expects embedded worksheet objects or cell values to attach directly to an Outlook message.
Observed behavior
Outlook Attachments.Add requires a valid file path, so embedded OLE objects or displayed cell values are not recognized as attachable files.
Before you start

Confirm whether cells A1:A8 contain full file paths such as C:\Reports\file.pdf or embedded OLE objects. In the VBA editor, enable the Microsoft Outlook Object Library reference before running attachment code.

Solution 1Recommended

Attach Valid File Paths from Worksheet Cells to an Outlook Email

Use this method when cells A1:A8 contain full file paths, because Outlook only accepts valid paths on disk rather than displayed values or embedded objects.

Outlook's Attachments.Add method requires a file path or a saved temporary file. A worksheet cell that shows a path must be validated with Dir before it is attached.

1
Open the VBA editor

Press Alt+F11 in Excel to open the Visual Basic for Applications editor, then click Insert > Module to create a new module.

2
Add the Outlook object reference

In the VBA editor, click Tools > References, then check Microsoft Outlook 16.0 Object Library so Outlook objects are available to the macro.

3
Validate each cell path

Read attachmentCell.Value into a filePath string, and use If Len(Dir(filePath)) > 0 Then objMail.Attachments.Add filePath, olByValue to attach only existing files.

4
Run the macro

Place the cursor inside the procedure and press F5, or go to the Developer tab > Macros, select the macro, and click Run to create the Outlook email.

Attach Valid File Paths from Worksheet Cells to an Outlook Email
Valid paths attach successfully: When each cell contains a complete file path and the file exists, the Outlook email receives real attachments instead of embedded object errors.
Free Microsoft Office alternative

Use WPS Office as a Free Alternative for Excel-Compatible Spreadsheet Workflows

Because Outlook attachment automation belongs to Microsoft Office itself, WPS Office offers a free, lightweight alternative for opening, editing, and saving Excel-compatible spreadsheets with a familiar interface and strong format compatibility.

Opens and saves .xlsx and .xls files without a Microsoft 365 subscriptionLightweight and familiar ribbon interface makes switching from Excel easierPreserves workbook formulas, formatting, and data when saving as Microsoft Excel filesFree to download for everyday spreadsheet and document tasksSupports VBA and macro-enabled workbooks in compatible WPS Office versions
microsoft office alternative - wps office

Frequently Asked Questions

Why does Outlook say it cannot attach a file when I use a worksheet cell value?

Outlook Attachments.Add requires a valid file path, not a displayed cell value or an embedded OLE object. Use Len(Dir(filePath)) to confirm the path exists before calling Attachments.Add.

How do I attach multiple files listed in cells A1:A8 with VBA?

Loop through the cells with a Long row counter, read each cell value into a string, validate it with Dir, and then call objMail.Attachments.Add filePath, olByValue for each existing file.

Can I attach embedded Excel worksheet objects directly to an Outlook email?

No, Outlook cannot attach an embedded OLE object directly as an email attachment. Export each embedded object to a temporary file first, then pass that temporary file path to Attachments.Add.

Do I need an Outlook object library reference in Excel VBA?

Yes. In the VBA editor, click Tools > References and check Microsoft Outlook 16.0 Object Library so Outlook objects such as MailItem and Attachments are available to your macro.