You can send the current workbook as an email attachment from Excel VBA using Outlook automation: create an Outlook application object, compose a mail item, attach ThisWorkbook.FullName, and call .Send (or .Display to review first). This works on Windows desktop Excel with the desktop Outlook app installed and configured; it is not supported on Excel for the web or Mac Excel without Outlook for Mac and the same automation permissions. The code below is the shortest reliable version, followed by the settings and pitfalls that decide whether it actually sends.
What You'll Need
- Windows desktop Excel (Microsoft 365 or a recent perpetual version) and desktop Outlook signed in with a configured mail account.
- The VBA project saved in a macro-enabled workbook (
.xlsm) or an add-in, so the code persists. - Access to the Visual Basic Editor: Developer tab > Visual Basic, or Alt+F11. If the Developer tab is hidden, enable it in File > Options > Customize Ribbon.
- Macro security set to allow the macro to run (File > Options > Trust Center > Trust Center Settings > Macro Settings).
- Outlook and Excel running in the same user session. Outlook automation from Excel fails if Outlook is running elevated (as administrator) and Excel is not, or vice versa.
Menu labels can differ slightly by Excel and Outlook version, device and region; the paths above are the standard Windows desktop ones.
Step-by-Step
- Save the workbook first.
ThisWorkbook.FullNameonly returns a real path after the file has been saved once. An unsaved workbook returns an empty string and the attachment step fails. - Open the VBA Editor with Alt+F11, then insert a standard module: Insert > Module. Keep the code in a module rather than a worksheet's code pane so it is easy to find and run.
- Paste the core procedure. Replace the placeholder recipient and subject with your own values:
Sub EmailWorkbook() Dim olApp As Object Dim olMail As Object Dim wbPath As String wbPath = ThisWorkbook.FullName If wbPath = "" Then MsgBox "Save the workbook before emailing it.", vbExclamation Exit Sub End If On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If olApp Is Nothing Then Set olApp = CreateObject("Outlook.Application") End If On Error GoTo 0 If olApp Is Nothing Then MsgBox "Outlook could not be started.", vbCritical Exit Sub End If Set olMail = olApp.CreateItem(0) With olMail .To = "recipient@example.com" .Subject = "Workbook: " & ThisWorkbook.Name .Body = "Attached is the current workbook." .Attachments.Add wbPath .Display ' change to .Send to send without review End With Set olMail = Nothing Set olApp = Nothing End Sub - Decide between Display and Send.
.Displayopens the draft so you can check the recipient, subject and attachment before sending;.Sendsends immediately. Start with.Displayuntil the procedure is proven. - Run the macro with F5 while the cursor is inside the procedure, or assign it to a button on the sheet (Developer > Insert > Button (Form Control)).
- Confirm the draft. In the Outlook window that appears, verify the attachment is the saved workbook, not a temporary copy, and that the recipient address is complete. Click Send.
- Handle Outlook security prompts. If Outlook shows a programmatic access warning, allow access for the session. If the organisation blocks programmatic sending entirely, the macro cannot bypass that; use
.Displayand send manually, or ask IT about the policy. - Save the workbook as .xlsm so the module survives closing and reopening. A plain .xlsx strips the VBA project on save.
Common Mistakes
- Attaching an unsaved workbook. The path is empty, so
.Attachments.Adderrors. Always checkFullNamefirst, as the code above does. - Using
ActiveWorkbookinstead ofThisWorkbook. If the user switches files,ActiveWorkbookpoints at the wrong file.ThisWorkbookis the one containing the macro. - Forgetting the Outlook reference. Early binding (declaring
Outlook.MailItem) requires a reference set in Tools > References. Late binding withObject, as shown, avoids that and works across Office versions. - Leaving objects open. Not releasing
olMailandolAppcan leave Outlook processes running in the background. Set them toNothing. - Running Excel as administrator. Outlook automation across different integrity levels fails with a permissions error. Run both applications normally.
- Assuming it works on the web or Mac. Excel for the web has no VBA, and Mac Excel requires Outlook for Mac plus the same automation permissions; test there separately rather than assuming parity.
Tips
- Use
.To,.CCand.BCCdeliberately; a typo in a hard-coded address sends the file to the wrong person. Consider reading the address from a cell and validating it is non-empty before sending. - Set
.SubjectfromThisWorkbook.Nameplus a date so recipients can tell versions apart. - If the workbook is large, attach a saved copy rather than the live file to avoid locking issues; save a copy to a temp folder, attach that, then delete it after sending.
- Keep the macro in a personal workbook or add-in if you want it available across files, rather than duplicating it in every workbook.
- Test with
.Displayand a recipient address you control before switching to.Send.
Troubleshooting
Nothing happens when the macro runs. Check that macros are enabled and that the code is in a standard module, not a sheet's code pane. Press Ctrl+G in the VBA Editor and check the Immediate window for errors.
"Object variable or With block variable not set". Outlook failed to start or CreateItem returned nothing. Confirm Outlook opens normally, is signed in, and that Excel and Outlook run at the same privilege level.
"The file could not be found". The workbook path is wrong or the file is unsaved. Save first and re-run; check ThisWorkbook.FullName in the Immediate window with ?ThisWorkbook.FullName.
Outlook blocks the send. A programmatic access prompt or organisational policy is stopping it. Allow access if prompted; if policy blocks it, use .Display and send manually. Do not attempt to bypass security settings.
The attachment is the wrong file. You are probably using ActiveWorkbook. Switch to ThisWorkbook and confirm the name in the draft before sending.
Frequently Asked Questions
Can I send the workbook without Outlook installed?
Not with this method. Outlook automation needs the desktop Outlook application. Alternatives are to save the file and attach it manually, or use a server-side mail service, which is outside Excel VBA's built-in capabilities.
Does this work in Excel for the web or on a Mac?
No for Excel for the web, which has no VBA. On Mac Excel, VBA exists but Outlook automation requires Outlook for Mac and the same permissions; test it there rather than assuming the Windows code runs unchanged.
How do I attach the workbook as PDF instead?
Export the sheet or workbook to PDF first (File > Export > Create PDF/XPS, or ExportAsFixedFormat in VBA), then attach the PDF path instead of ThisWorkbook.FullName.
Why does the macro send from the wrong account?
Outlook uses the default account unless you set .SendUsingAccount. If multiple accounts are configured, set the account explicitly or send from the default and check the From line in the draft.
Can I attach only part of the workbook?
No, an attachment is a whole file. Create a copy containing only the needed sheets, save it, attach that copy, and delete it afterwards if it was temporary.
Is it safe to use .Send automatically?
Only after testing. .Send bypasses the review step, so a wrong address or missing attachment goes out immediately. Use .Display until the logic is proven, then switch deliberately.