How to save a worksheet as PDF file and email it as an attachment through Outlook?
In daily work, you may often encounter situations where you need to share a specific worksheet with colleagues or clients, but want to ensure the file format is fixed and secure. Sending a worksheet as a PDF file via Outlook is a common requirement, especially for documenting reports, sending invoices, or sharing finalized data that should not be easily modified. Traditionally, this involves manually saving the worksheet as a PDF, opening Outlook, composing an email, attaching the PDF, and sending— which is tedious and time-consuming, particularly if repeated frequently or when handling multiple sheets.
This article guides you step by step on how to automate the process of converting a worksheet to PDF and immediately attaching it to an Outlook email directly from Excel, helping you save significant time and avoid repetitive manual work. You will find a VBA code solution, along with details on operation, advantages, application scenarios, and practical tips.
Save a worksheet as PDF file and email it as an attachment with VBA code
Save a worksheet as PDF file and email it as an attachment with VBA code
To speed up the process of exporting an Excel worksheet as a PDF file and emailing it through Outlook, you can use the following VBA code. This approach is especially useful if you regularly need to send personalized reports, invoices, or other data snapshots straight from Excel, as it completely automates the saving and emailing steps.
Before applying this method, make sure that Microsoft Outlook is installed and set as your default mail client. The code works best when macros are enabled in your Excel environment.
1. Open the worksheet you want to save and send as a PDF. Press Alt + F11 at the same time to launch the Microsoft Visual Basic for Applications (VBA) editor.
2. In the VBA window, go to the menu and click Insert > Module. This will create a new code module. Then copy and paste the following VBA code into the module's Code window.
VBA code: Save a worksheet as PDF file and email it as an attachment
Sub Saveaspdfandsend()
Dim xSht As Worksheet
Dim xFileDlg As FileDialog
Dim xFolder As String
Dim xYesorNo As Integer
Dim xOutlookObj As Object
Dim xEmailObj As Object
Dim xUsedRng As Range
Set xSht = ActiveSheet
Set xFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
If xFileDlg.Show = True Then
xFolder = xFileDlg.SelectedItems(1)
Else
MsgBox "You must specify a folder to save the PDF into." & vbCrLf & vbCrLf & "Press OK to exit this macro.", vbCritical, "Must Specify Destination Folder"
Exit Sub
End If
xFolder = xFolder + "\" + xSht.Name + ".pdf"
'Check if file already exist
If Len(Dir(xFolder)) > 0 Then
xYesorNo = MsgBox(xFolder & " already exists." & vbCrLf & vbCrLf & "Do you want to overwrite it?", _
vbYesNo + vbQuestion, "File Exists")
On Error Resume Next
If xYesorNo = vbYes Then
Kill xFolder
Else
MsgBox "if you don't overwrite the existing PDF, I can't continue." _
& vbCrLf & vbCrLf & "Press OK to exit this macro.", vbCritical, "Exiting Macro"
Exit Sub
End If
If Err.Number <> 0 Then
MsgBox "Unable to delete existing file. Please make sure the file is not open or write protected." _
& vbCrLf & vbCrLf & "Press OK to exit this macro.", vbCritical, "Unable to Delete File"
Exit Sub
End If
End If
Set xUsedRng = xSht.UsedRange
If Application.WorksheetFunction.CountA(xUsedRng.Cells) <> 0 Then
'Save as PDF file
xSht.ExportAsFixedFormat Type:=xlTypePDF, Filename:=xFolder, Quality:=xlQualityStandard
'Create Outlook email
Set xOutlookObj = CreateObject("Outlook.Application")
Set xEmailObj = xOutlookObj.CreateItem(0)
With xEmailObj
.Display
.To = ""
.CC = ""
.Subject = xSht.Name + ".pdf"
.Attachments.Add xFolder
If DisplayEmail = False Then
'.Send
End If
End With
Else
MsgBox "The active worksheet cannot be blank"
Exit Sub
End If
End Sub
3. After pasting the code, press F5 or click Run in the VBA editor to execute the macro. A folder selection dialog will appear. Choose the target folder where the PDF file should be saved, then click OK to continue.
Notes and Practical Tips:
4. Once the process completes, a new Outlook email window is generated, with the PDF file attached. The subject line is prefilled with the worksheet's name ending in ".pdf"; you can edit the email content, add recipients, and then send as needed. This reduces errors and increases efficiency over manual attachment.
This VBA-based approach is most efficient when you regularly need to distribute finalized worksheets as PDF attachments and minimizes repetitive manual steps. Its limitations include dependency on Outlook, inability to batch multiple sheets at once, and the need to enable macros. For more complex workflows, such as sending multiple worksheets in one go or additional automation, consider using Excel add-ins or built-in features.
Alternative solution: If VBA macros are not suitable for your environment, such as when macros are restricted, you can manually use Excel's built-in Export or Save As function to save your worksheet as PDF, then attach and send it in Outlook. This method, while requiring more steps, is universally available without special permissions or scripting knowledge.
Easily save a worksheet or multiple worksheets as separate PDF files at once:
The Split Workbook utility of Kutools for Excel can help you easily save a worksheet or multiple worksheets as separate PDF files at once as the below demo shown. Download and try it now! (30-day free trail)
Related articles:
- How to save an Excel filename with timestamp?
- How to use Save As function to automatically overwriting existing file in Excel?
- How to save, export multiple/all sheets to separate csv or text files in Excel?
- How to disable or do not allow Save & Save As options in Excel?
- How to disable workbook save but only allow save as in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.





- All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license — set up in minutes (MSI-ready)
- Works better together — streamlined productivity across Office apps
- 30-day full-featured trial — no registration, no credit card
- Best value — save vs buying individual add-in