How to Attach an Excel Worksheet as a PDF Attachment in Your Outlook Email

If you want to quickly convert an Excel worksheet to a PDF file and then attach this PDF file to an Outlook email to send it, you can utilize the method introduced in this article. It is using VBA to accomplish this task within seconds.

To be honest, to attach an entire Excel workbook as a PDF attachment in an email is pretty easy. You can first save the workbook as a PDF file and then create a new Outlook email and attach the PDF file to this mail. However, in Excel, there is no such a direct function to convert a single worksheet to a PDF file and mail it. Thus, if you want to quickly attach an Excel worksheet as a PDF attachment in an email, you can utilize the following means.

Attach an Excel Worksheet as a PDF Attachment in Your Outlook Email

Attach an Excel Worksheet as a PDF Attachment in Your Email

  1. In the first place, you need to open the source Excel worksheet as normal.
  2. Then in the Excel window, you should press “Alt + F11” key buttons.
  3. Subsequently, you will get access to the Excel VBA editor window in success.
  4. After that, you ought to open the “ThisWorkbook” project.
  5. Next copy and paste the following VBA code into this project window.
Sub SendWorksheet_AsPDFAttachment_OutlookEmail()
    Dim objFileSystem As Object
    Dim strTempFile As String
    Dim objOutlookApp As Outlook.Application
    Dim objMail As Outlook.MailItem
 
    'Specify the worksheet name
    Sheets("DataNumen Staff").Activate
    ActiveSheet.UsedRange.Select
    ThisWorkbook.Sheets(Array("DataNumen Staff")).Select
 
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    strTempFile = objFileSystem.GetSpecialFolder(2).Path & "\" & ActiveSheet.Name & " in " & ThisWorkbook.Name & ".pdf"
 
    'export the specific worksheet as PDF
    Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strTempFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
 
    'Create a new email
    Set objOutlookApp = CreateObject("Outlook.Application")
    Set objMail = objOutlookApp.CreateItem(olMailItem)
 
    'Attach the PDF file
    objMail.Attachments.Add strTempFile
    objMail.Display '==>display this email
 
    'Delete the temp PDF file
    objFileSystem.DeleteFile (strTempFile)
End Sub

VBA Code - Attach an Excel Worksheet as a PDF Attachment in Your Outlook Email

  1. Eventually, to trigger the new macro, you can hit the “Run” icon in the toolbar or straightly press the “F5” key button.
  2. After the macro finishes running, a new Outlook email will display at once. In it, you can see a PDF file in the “Attached” line, like the following screenshot:Attached PDF File

Protect Outlook File from Getting Damaged

As we all know, Outlook is prone to corruption, similar to Word documents and Excel workbooks. Therefore, we should understand how to protect Outlook from corruption. Due to the fact that viruses have become more and more complex and rampant, Outlook is frequently corrupt due to virus infection and malware attack. In this situation, you have to install reliable antivirus software and disable auto downloading external files. Furthermore, you’d better get hold of anther robust Outlook fix tool, like DataNumen Outlook Repair. It’s able to provide you with the most effective remedy in the event of Outlook corruption.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including fix sql and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.