{"id":12156,"date":"2012-08-12T12:00:48","date_gmt":"2012-08-12T12:00:48","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/?p=2318"},"modified":"2022-08-12T11:33:30","modified_gmt":"2022-08-12T11:33:30","slug":"mail-one-sheet","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/","title":{"rendered":"How to Send ActiveSheet as Attachment in mail"},"content":{"rendered":"

In previous article<\/a> of Send Email Tutorial using Excel Macro<\/a>, you learnt how to send current workbook as attachment in the email.
\nIn this Article you are going to learn how to send the ActiveSheet as an attachment in Email. The below function sends the active sheet as an attachment in email.
\n<\/p>\n

\r\n\r\nSub Email_One_ActiveSheet()\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 FileExt As String\r\n    Dim TempFileName As String\r\n    Dim FileFullPath As String\r\n    Dim FileFormat As Variant\r\n    Dim Wb1 As Workbook\r\n    Dim Wb2 As Workbook\r\n\r\n    With Application\r\n        .ScreenUpdating = False\r\n        .EnableEvents = False\r\n    End With\r\n    Set Wb1 = ThisWorkbook\r\n    ActiveSheet.Copy\r\n    Set Wb2 = ActiveWorkbook\r\n    \r\n    'Below code will get the File Extension and\r\n    'the file format which we want to save the copy\r\n    'of the workbook with the active sheet.\r\n    \r\n    With Wb2\r\n        If Val(Application.Version) < 12 Then\r\n             FileExt = ".xls": FileFormat = -4143\r\n        Else\r\n            Select Case Wb1.FileFormat\r\n            Case 51: FileExt = ".xlsx": FileFormat = 51\r\n            Case 52:\r\n                If .HasVBProject Then\r\n                    FileExt = ".xlsm": FileFormat = 52\r\n                Else\r\n                    FileExt = ".xlsx": FileFormat = 51\r\n                End If\r\n            Case 56: FileExt = ".xls": FileFormat = 56\r\n            Case Else: FileExt = ".xlsb": FileFormat = 50\r\n            End Select\r\n        End If\r\n    End With\r\n\r\n    'Save your workbook in your temp folder of your system\r\n    'below code gets the full path of the temporary folder\r\n    'in your system\r\n    \r\n    TempFilePath = Environ$("temp") & "\\"\r\n\r\n    'Now append a date and time stamp\r\n    'in your new file\r\n    \r\n    TempFileName = Wb1.Name & "-" & Format(Now, "dd-mmm-yy h-mm-ss")\r\n\r\n    'Complete path of the file where it is saved\r\n    FileFullPath = TempFilePath & TempFileName & FileExt\r\n    \r\n    'Now save your currect workbook at the above path\r\n    Wb2.SaveAs FileFullPath, FileFormat:=FileFormat\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 temp file 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 close and delete the temp file from the\r\n    'temp folder\r\n    Wb2.Close SaveChanges:=False\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\nEnd Sub\r\n\r\n<\/code><\/pre>\n

<\/p>\n

\nNote:<\/strong> The above code sends the activesheet as an attachment by email. But if you want to send any particular Sheet in the mail as an attachment, then use the below line in the above code:<\/p>\n

ActiveSheet.Copy => Sheets(“Sheet_Name”).Copy<\/strong>\n<\/p><\/blockquote>\n

<\/p>\n<\/span>","protected":false},"excerpt":{"rendered":"

In previous article of Send Email Tutorial using Excel Macro, you learnt how to send current workbook as attachment in the email. In this Article you are going to learn how to send the ActiveSheet as an attachment in Email. The below function sends the active sheet as an attachment in email. Sub Email_One_ActiveSheet() ‘Do […]<\/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":[5205],"tags":[],"yoast_head":"\nHow to Send ActiveSheet as Attachment in mail - Let's excel in Excel<\/title>\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\/08\/mail-one-sheet\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Send ActiveSheet as Attachment in mail\" \/>\n<meta property=\"og:description\" content=\"In previous article of Send Email Tutorial using Excel Macro, you learnt how to send current workbook as attachment in the email. In this Article you are going to learn how to send the ActiveSheet as an attachment in Email. The below function sends the active sheet as an attachment in email. Sub Email_One_ActiveSheet() 'Do […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/\" \/>\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-08-12T12:00:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-12T11:33:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/vmlogger.com_-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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\/08\/mail-one-sheet\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/\"},\"author\":{\"name\":\"Vishwamitra Mishra\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"headline\":\"How to Send ActiveSheet as Attachment in mail\",\"datePublished\":\"2012-08-12T12:00:48+00:00\",\"dateModified\":\"2022-08-12T11:33:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/\"},\"wordCount\":102,\"commentCount\":10,\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"articleSection\":[\"Email\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/\",\"name\":\"How to Send ActiveSheet as Attachment in mail - Let's excel in Excel\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\"},\"datePublished\":\"2012-08-12T12:00:48+00:00\",\"dateModified\":\"2022-08-12T11:33:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/vmlogger.com\/excel\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Email\",\"item\":\"https:\/\/vmlogger.com\/excel\/send-email\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Send ActiveSheet as Attachment in mail\"}]},{\"@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\":\"required name=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:\/\/twitter.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":"How to Send ActiveSheet as Attachment in mail - Let's excel in Excel","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\/08\/mail-one-sheet\/","og_locale":"en_US","og_type":"article","og_title":"How to Send ActiveSheet as Attachment in mail","og_description":"In previous article of Send Email Tutorial using Excel Macro, you learnt how to send current workbook as attachment in the email. In this Article you are going to learn how to send the ActiveSheet as an attachment in Email. The below function sends the active sheet as an attachment in email. Sub Email_One_ActiveSheet() 'Do […]","og_url":"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/","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-08-12T12:00:48+00:00","article_modified_time":"2022-08-12T11:33:30+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/vmlogger.com_-1.png","type":"image\/png"}],"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\/08\/mail-one-sheet\/#article","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/"},"author":{"name":"Vishwamitra Mishra","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"headline":"How to Send ActiveSheet as Attachment in mail","datePublished":"2012-08-12T12:00:48+00:00","dateModified":"2022-08-12T11:33:30+00:00","mainEntityOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/"},"wordCount":102,"commentCount":10,"publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"articleSection":["Email"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/","url":"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/","name":"How to Send ActiveSheet as Attachment in mail - Let's excel in Excel","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/#website"},"datePublished":"2012-08-12T12:00:48+00:00","dateModified":"2022-08-12T11:33:30+00:00","breadcrumb":{"@id":"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vmlogger.com\/excel\/2012\/08\/mail-one-sheet\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vmlogger.com\/excel\/"},{"@type":"ListItem","position":2,"name":"Email","item":"https:\/\/vmlogger.com\/excel\/send-email\/"},{"@type":"ListItem","position":3,"name":"How to Send ActiveSheet as Attachment in mail"}]},{"@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":"required name=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:\/\/twitter.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\/12156"}],"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=12156"}],"version-history":[{"count":0,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12156\/revisions"}],"wp:attachment":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/media?parent=12156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/categories?post=12156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/tags?post=12156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}