{"id":12168,"date":"2012-11-25T07:05:34","date_gmt":"2012-11-25T07:05:34","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/?p=2608"},"modified":"2022-09-14T16:13:57","modified_gmt":"2022-09-14T16:13:57","slug":"send-worksheet-as-a-pdf-attachment","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/","title":{"rendered":"Send Sheet as a PDF attachment in Email"},"content":{"rendered":"

Dear Readers,<\/p>\n

\nIn my previous article<\/a>, you saw how to save an Excel Sheet as PDF file<\/a>. Now you know, how to save an Excel Sheet as a pdf. Also, we have seen how to send the ActiveSheet as an attachment in Email<\/a>. In this article, I am going to show you how to send the ActiveSheet as an Attachment in PDF format. You can also download the Excel Workbook at the end of this article and play around with the code. It’s all yours \ud83d\ude42\n<\/p>\n

<\/p>\n

<< Go Back to the Excel Tutorial Page<\/h2>\n

<\/a>
\nBelow is the code, which works at the below logic:<\/p>\n

\n1. Save the ActiveSheet as PDF<\/a> in Temporary Folder of the System
\n2. Attach the File in Outlook New Email
\n3. Send the Email
\n4. Delete the PDF file from the Temp Folder.\n<\/p>\n

\r\nSub Email_ActiveSheet_As_PDF()\r\n    \r\n'Do not forget to change the email ID\r\n'before running this code\r\n    \r\n    Dim OlApp As Object\r\n    Dim NewMail As Object\r\n    Dim TempFilePath As String\r\n    Dim TempFileName As String\r\n    Dim FileFullPath As String\r\n    \r\n    With Application\r\n        .ScreenUpdating = False\r\n        .EnableEvents = False\r\n    End With\r\n    \r\n' Temporary file path where pdf\r\n' file will be saved before\r\n' sending it in email by attaching it.\r\n    \r\n    TempFilePath = Environ$(\"temp\") & \"\\\"\r\n    \r\n' Now append a date and time stamp\r\n' in your pdf file name. Naming convention\r\n' can be changed based on your requirement.\r\n    \r\n    TempFileName = ActiveSheet.Name & \"-\" & Format(Now, \"dd-mmm-yy h-mm-ss\") & \".pdf\"\r\n    \r\n'Complete path of the file where it is saved\r\n    FileFullPath = TempFilePath & TempFileName\r\n    \r\n'Now Export the Activesshet as PDF with the given File Name and path\r\n    \r\n    On Error GoTo err\r\n    With ActiveSheet\r\n        .ExportAsFixedFormat _\r\n        Type:=xlTypePDF, _\r\n        Filename:=FileFullPath, _\r\n        Quality:=xlQualityStandard, _\r\n        IncludeDocProperties:=True, _\r\n        IgnorePrintAreas:=False, _\r\n        OpenAfterPublish:=False\r\n    End With\r\n    \r\n'Now open a new mail\r\n    \r\n    Set OlApp = CreateObject(\"Outlook.Application\")\r\n    Set NewMail = OlApp.CreateItem(0)\r\n    \r\n    On Error Resume Next\r\n    With NewMail\r\n        .To = \"info@learnexcelmacro.com\"\r\n        .CC = \"info@learnexcelmacro.com\"\r\n        .BCC = \"info@learnexcelmacro.com\"\r\n        .Subject = \"Type your Subject here\"\r\n        .Body = \"Type the Body of your mail\"\r\n        .Attachments.Add FileFullPath '--- full path of the pdf where it is saved\r\n        .Send   'or use .Display to show you the email before sending it.\r\n    End With\r\n    On Error GoTo 0\r\n    \r\n'Since mail has been sent with the attachment\r\n'Now delete the pdf file from the temp folder\r\n    \r\n    Kill FileFullPath\r\n    \r\n'set nothing to the objects created\r\n    Set NewMail = Nothing\r\n    Set OlApp = Nothing\r\n    \r\n'Now set the application properties back to true\r\n    With Application\r\n        .ScreenUpdating = True\r\n        .EnableEvents = True\r\n    End With\r\n    MsgBox (\"Email has been Sent Successfully\")\r\n    Exit Sub\r\nerr:\r\n        MsgBox err.Description\r\n\r\nEnd Sub\r\n\r\n<\/code><\/pre>\n
\n\"Download<\/a>\n<\/div>\n<\/span>","protected":false},"excerpt":{"rendered":"

Dear Readers, In my previous article, you saw how to save an Excel Sheet as PDF file. Now you know, how to save an Excel Sheet as a pdf. Also, we have seen how to send the ActiveSheet as an attachment in Email. In this article, I am going to show you how to send […]<\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1246,1675,1682],"tags":[],"class_list":["post-12168","post","type-post","status-publish","format-standard","hentry","category-macro","category-excel-macro-for-beginners","category-popular-articles"],"yoast_head":"\nSend Sheet as a PDF attachment in Email - Let's excel in Excel<\/title>\n<meta name=\"description\" content=\"Convert a sheet into a PDF file and send it as an attachment in an email. Send PDF as an attachment in an email. Send sheet in email as attachment\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Send Sheet as a PDF attachment in Email\" \/>\n<meta property=\"og:description\" content=\"Convert a sheet into a PDF file and send it as an attachment in an email. Send PDF as an attachment in an email. Send sheet in email as attachment\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/\" \/>\n<meta property=\"og:site_name\" content=\"Let's excel in Excel\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:author\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-25T07:05:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-14T16:13:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2011\/11\/download.jpg\" \/>\n<meta name=\"author\" content=\"Vishwamitra Mishra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/www.twitter.com\/learnexcelmacro\" \/>\n<meta name=\"twitter:site\" content=\"@learnexcelmacro\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vishwamitra Mishra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/\"},\"author\":{\"name\":\"Vishwamitra Mishra\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"headline\":\"Send Sheet as a PDF attachment in Email\",\"datePublished\":\"2012-11-25T07:05:34+00:00\",\"dateModified\":\"2022-09-14T16:13:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/\"},\"wordCount\":142,\"commentCount\":30,\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"image\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2011\/11\/download.jpg\",\"articleSection\":[\"Excel Macro\",\"Excel Macro Tutorial\",\"Popular Articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/\",\"name\":\"Send Sheet as a PDF attachment in Email - Let's excel in Excel\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2011\/11\/download.jpg\",\"datePublished\":\"2012-11-25T07:05:34+00:00\",\"dateModified\":\"2022-09-14T16:13:57+00:00\",\"description\":\"Convert a sheet into a PDF file and send it as an attachment in an email. Send PDF as an attachment in an email. Send sheet in email as attachment\",\"breadcrumb\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#primaryimage\",\"url\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2011\/11\/download.jpg\",\"contentUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2011\/11\/download.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/vmlogger.com\/excel\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel Macro\",\"item\":\"https:\/\/vmlogger.com\/excel\/macro\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Send Sheet as a PDF attachment in Email\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\",\"url\":\"https:\/\/vmlogger.com\/excel\/\",\"name\":\"Let's excel in Excel\",\"description\":\"Let's share knowledge\",\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/vmlogger.com\/excel\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\",\"name\":\"Vishwamitra Mishra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"contentUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"width\":528,\"height\":560,\"caption\":\"Vishwamitra Mishra\"},\"logo\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\"},\"description\":\"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.\",\"sameAs\":[\"http:\/\/www.learnexcelmacro.com\",\"http:\/\/www.facebook.com\/vmlogger\",\"https:\/\/x.com\/https:\/\/www.twitter.com\/learnexcelmacro\",\"https:\/\/www.youtube.com\/c\/VMLogger\"],\"url\":\"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Send Sheet as a PDF attachment in Email - Let's excel in Excel","description":"Convert a sheet into a PDF file and send it as an attachment in an email. Send PDF as an attachment in an email. Send sheet in email as attachment","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/","og_locale":"en_US","og_type":"article","og_title":"Send Sheet as a PDF attachment in Email","og_description":"Convert a sheet into a PDF file and send it as an attachment in an email. Send PDF as an attachment in an email. Send sheet in email as attachment","og_url":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/","og_site_name":"Let's excel in Excel","article_publisher":"http:\/\/www.facebook.com\/vmlogger","article_author":"http:\/\/www.facebook.com\/vmlogger","article_published_time":"2012-11-25T07:05:34+00:00","article_modified_time":"2022-09-14T16:13:57+00:00","og_image":[{"url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2011\/11\/download.jpg"}],"author":"Vishwamitra Mishra","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/www.twitter.com\/learnexcelmacro","twitter_site":"@learnexcelmacro","twitter_misc":{"Written by":"Vishwamitra Mishra","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#article","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/"},"author":{"name":"Vishwamitra Mishra","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"headline":"Send Sheet as a PDF attachment in Email","datePublished":"2012-11-25T07:05:34+00:00","dateModified":"2022-09-14T16:13:57+00:00","mainEntityOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/"},"wordCount":142,"commentCount":30,"publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"image":{"@id":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#primaryimage"},"thumbnailUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2011\/11\/download.jpg","articleSection":["Excel Macro","Excel Macro Tutorial","Popular Articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/","url":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/","name":"Send Sheet as a PDF attachment in Email - Let's excel in Excel","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/#website"},"primaryImageOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#primaryimage"},"image":{"@id":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#primaryimage"},"thumbnailUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2011\/11\/download.jpg","datePublished":"2012-11-25T07:05:34+00:00","dateModified":"2022-09-14T16:13:57+00:00","description":"Convert a sheet into a PDF file and send it as an attachment in an email. Send PDF as an attachment in an email. Send sheet in email as attachment","breadcrumb":{"@id":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#primaryimage","url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2011\/11\/download.jpg","contentUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2011\/11\/download.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/vmlogger.com\/excel\/2012\/11\/send-worksheet-as-a-pdf-attachment\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vmlogger.com\/excel\/"},{"@type":"ListItem","position":2,"name":"Excel Macro","item":"https:\/\/vmlogger.com\/excel\/macro\/"},{"@type":"ListItem","position":3,"name":"Send Sheet as a PDF attachment in Email"}]},{"@type":"WebSite","@id":"https:\/\/vmlogger.com\/excel\/#website","url":"https:\/\/vmlogger.com\/excel\/","name":"Let's excel in Excel","description":"Let's share knowledge","publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vmlogger.com\/excel\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5","name":"Vishwamitra Mishra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/","url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","contentUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","width":528,"height":560,"caption":"Vishwamitra Mishra"},"logo":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/"},"description":"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.","sameAs":["http:\/\/www.learnexcelmacro.com","http:\/\/www.facebook.com\/vmlogger","https:\/\/x.com\/https:\/\/www.twitter.com\/learnexcelmacro","https:\/\/www.youtube.com\/c\/VMLogger"],"url":"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/"}]}},"_links":{"self":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12168"}],"collection":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/comments?post=12168"}],"version-history":[{"count":0,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12168\/revisions"}],"wp:attachment":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/media?parent=12168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/categories?post=12168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/tags?post=12168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}