Email Active Sheet in Excel
Wisdom by Data Wisdom by Data
1.54K subscribers
64 views
0

 Published On Mar 31, 2024

Discover the simple secret I've mastered to instantly attach any active Excel sheet to an email, right from within Excel! Say goodbye to the tedious process of saving and attaching files. In this easy-to-follow tutorial, I'll show you how to use a VBA code that I created to make your life easier. No coding skills? No problem! This method is designed for anyone to use, making your Excel tasks faster and more efficient. Watch now and elevate your productivity with this game-changing Excel hack! 🚀📊✉️

VBA Code Used in this tutorial :
*********************
Sub EmailActiveSheet()

Dim SourceWorksheet As Worksheet
Dim TempWorkbook As Workbook
Dim TempFilePath As String
Dim OutlookApp As Object
Dim OutlookMail As Object

' Set the active worksheet
Set SourceWorksheet = ActiveSheet

' Copy the active sheet to a new workbook
SourceWorksheet.Copy
Set TempWorkbook = ActiveWorkbook

' Save the new workbook to a temporary file
TempFilePath = Environ$("temp") & "\" & SourceWorksheet.Name & ".xlsx"
TempWorkbook.SaveAs Filename:=TempFilePath, FileFormat:=xlOpenXMLWorkbook

' Create a new Outlook mail item
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)

' Set up the email
With OutlookMail
.To = "[email protected]" ' Change to recipient's email address
.CC = "" ' Add CC email addresses if needed
.BCC = "" ' Add BCC email addresses if needed
.Subject = "Subject Here" ' Change email subject
.Body = "The body of your email goes here." ' Change email body
.Attachments.Add TempFilePath ' Attach the new workbook
.Display ' or use .Send to send the email automatically
End With

' Clean up
TempWorkbook.Close SaveChanges:=False
Kill TempFilePath ' Delete the temporary file
Set OutlookMail = Nothing
Set OutlookApp = Nothing
Set TempWorkbook = Nothing

End Sub
*********************

👨‍💻 LET ME BE YOUR MENTOR: https://topmate.io/mehran_vahedi

📸 SOCIAL : Connect with me on X and LinkedIn :

X : @WisdomByData
LinkedIn :   / mehranvahedi  

🔗 Check out my Skillsoft Courses : https://linktr.ee/MySkillsoftCourses

#ExcelTips, #ProductivityHack, #VBA, #EmailAutomation, #ExcelTutorial, #Office365, #DataManagement, #TechTips, #BusinessSolutions, #TimeSavingTips

show more

Share/Embed