VBA & Macro Problems

How to Create an Excel Button to Email a Workbook via Outlook

Steve KSteve K Oct 23, 2026 871 views

Question details

The user wants to create a clickable button within an Excel spreadsheet that automatically generates an Outlook email and attaches the active workbook.

How to Create an Excel Button to Email a Workbook Through Outlook
Product
Microsoft Excel
Device & OS
not provided
Scenario
Automating the workflow of sharing a completed spreadsheet by embedding a one-click email button directly inside the document.
Observed behavior
The user needs to implement a VBA macro to trigger Outlook, attach the file, and either display the draft for review or send it automatically.
Before you start

Ensure that Microsoft Outlook is installed on your computer and set as your default email application. Additionally, you will need to enable the Developer tab in Excel to write and assign the necessary VBA macro.

Solution 1Recommended

Use VBA to Create an Email Button

Write a VBA macro that integrates with Outlook to attach the workbook, then assign that macro to a clickable shape or button in your sheet.

By utilizing Excel's Visual Basic for Applications (VBA), you can automate the creation of an Outlook MailItem. This allows you to define the recipient, subject line, and automatically attach the active workbook.

You can configure the code to either show the email draft so you can review it before sending, or bypass the review window and send it instantly in the background.

1
Open the VBA Editor

Press the Alt + F11 keys on your keyboard to launch the Visual Basic for Applications window.

2
Insert a New Module

In the top menu, click 'Insert' and select 'Module'. Paste your Outlook mailing VBA script into the blank window (e.g., code utilizing CreateObject("Outlook.Application")).

3
Choose Display or Send

Within your VBA code block, use the '.Display' command if you want the Outlook window to pop up for a manual review. Alternatively, change it to '.Send' to deliver the email automatically without any pop-ups.

4
Assign the Macro to a Button

Close the VBA editor and return to your spreadsheet. Go to 'Insert' > 'Shapes' and draw a shape to act as your button. Right-click the shape, select 'Assign Macro', choose the script you just created, and click 'OK'.

Use VBA to Create an Email Button
Save as Macro-Enabled: Remember to save your file as an Excel Macro-Enabled Workbook (.xlsm). If you save it as a standard .xlsx file, your VBA code and button functionality will be lost.
Seamless Document Sharing

Easily Automate and Share Workbooks with WPS Spreadsheet

WPS Office Spreadsheet provides excellent support for VBA macros, allowing you to easily map automated email scripts to custom buttons. Furthermore, its built-in sharing features make sending files via email faster than ever without requiring complex setup.

  1. 1. Open Your Workbook: Launch WPS Spreadsheet and open the document you wish to share or automate.
  2. 2. Utilize VBA or Built-in Sharing: Use the built-in Developer tab to insert your Outlook VBA macro, or simply click the 'Share' button in the top right corner of the application.
  3. 3. Send via Email: Choose the 'Email' option from the Share menu to automatically package your workbook and open it as an attachment in your default email client.
Fully compatible with Microsoft Excel (.xlsx and .xlsm formats)Advanced support for VBA macros and automated scriptsBuilt-in 'Share' options to email files in a single clickLightweight, fast, and completely free to use
microsoft office alternative - wps office

Frequently Asked Questions

Why is the 'Mail To' command missing from my Excel ribbon?

In newer Microsoft 365 updates, Microsoft phased out the legacy 'Mail To' command from the Quick Access Toolbar. Users are now encouraged to use the 'Share' button in the top right corner or implement VBA macros for custom email workflows.

What is the difference between .Display and .Send in my VBA macro?

The '.Display' command forces the Outlook email draft to pop up on your screen, allowing you to review the recipients, subject, and body before manually clicking Send. The '.Send' command bypasses this review window and dispatches the email instantly in the background.

Can I email only a specific worksheet instead of the entire workbook?

Yes, but you will need a slightly different VBA script. The macro must first copy the active worksheet into a temporary new workbook, attach that temporary file to the Outlook email, and then delete the temporary file from your hard drive once the email is sent or displayed.

Why does my macro fail to open Outlook?

This usually occurs if Outlook is not set as your system's default email client, or if the Outlook Object Library reference is not enabled in the VBA editor. You can enable it by going to 'Tools' > 'References' in the VBA window and checking 'Microsoft Outlook Object Library'.