How to Quickly Attach Selected Cells in an Excel Worksheet as PDF File to an Outlook Email

Some users frequently need to extract the selected cells in an Excel worksheet to a PDF file and then send out this PDF file via Outlook email to someone. Thus, here we will introduce you a method to quickly get it.

In the previous article – “2 Methods to Quickly Send Selected Cells in an Excel Worksheet as an Outlook Email“, you can learn how to quickly copy and paste the selected cells to the body of Outlook email. Similar to that, many users would like to send the selected cells as a PDF attachment in an Outlook email. Therefore, in the followings, we will introduce such a quick method.

Attach Selected Cells in an Excel Worksheet as PDF File to an Email

  1. At the very beginning, open the specific Excel worksheet.
  2. Then, select the cells that you want to export as PDF.Select Cells
  3. Next, press “Alt + F11” to launch Excel VBA editor.
  4. Subsequently, in the window, add reference to “MS Outlook Object Library” in accordance to “How to Add an Object Library Reference in VBA“.
  5. Later, put the following code into an unused module or project.
Sub SendSelectedCells_AsPDFinOutlookEmail()
    Dim objSelection As Excel.Range
    Dim objTempWorkbook As Excel.Workbook
    Dim objTempWorksheet As Excel.Worksheet
    Dim objFileSystem As Object
    Dim strPDFFile As String
    Dim objOutlookApp As Outlook.Application
    Dim objNewEmail As Outlook.MailItem
    'Copy the selected cells
    Set objSelection = Selection
    'Paste the copied cells into a temp worksheet
    Set objTempWorkbook = Excel.Application.Workbooks.Add(1)
    Set objTempWorksheet = objTempWorkbook.Sheets(1)
    With objTempWorksheet.Cells(1)
        .PasteSpecial xlPasteValues
        .PasteSpecial xlPasteColumnWidths
        .PasteSpecial xlPasteFormats
    End With
    'Export temp workbook as a pdf file
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    strPDFFile = Left(ThisWorkbook.Name, (Len(ThisWorkbook.Name) - 5)) & ".pdf"
    strPDFFile = objFileSystem.GetSpecialFolder(2).Path & "\" & strPDFFile

    objTempWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strPDFFile, 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 strPDFFile
    'Delete the temp PDF file
    objTempWorkbook.Close (False)
    objFileSystem.DeleteFile (strPDFFile)
End Sub

VBA Code - Attach Selected Cells in an Excel Worksheet as PDF File to an Email

  1. After that, run this macro directly by pressing the “F5” key button or clicking the “Run” icon in toolbar.
  2. At once, a new Outlook email will be displayed, which is attached with a PDF file, as shown in the screenshot below.New Email with PDF Attachment
  3. Now, you can double click on the PDF attachment to open it. It will look like the following image.Extracted Cells in PDF

Keep Suspicious Attachments at Bay

Outlook is pretty convenient in terms of dealing with attachments. You can send, receive, remove and save attachments at will. However, in this respect, there is a potential and great risk. That involves whether the attachments are malicious or not. If the attachments contain dangerous macros, when you download them, the Outlook data will be in danger of corruption. One of the most troublesome issues that the majority of users don’t want to come across is Outlook damage. It is far more difficult to be settled in comparison to small Outlook errors. In general, at that point, you have to resort to a proficient PST repair tool, such as DataNumen Outlook Repair in that Scanpst will not make effects in face of such a trouble.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupt SQL Server and outlook repair software products. For more information visit

Comments are closed.