Email Current Workbook & or Other Attachments

Add to Favorites
This macro will send the current workbook in an email through Microsoft Outlook. The Macro allows you to send the most recently saved version of the excel file you are working in as an attachment. You must use the email client Outlook and you will need to have an internet connection. The specifics of the email are all contained within the macro. This means that you will have to edit certain portions of the macro in order to send an email to the desired recipients and also with the desired message.

NOTE
In the macro code you should notice a series of lines which start at the line ".To" then ".CC" etc. This text reads exactly like it does in an email and you should fill in the space where it says ADD TEXT HERE with exactly what you would put in these areas of a regular email.

Where it reads ".To" and then says JOHNDOE@TEST.COM, replace this sample email with the email address or addresses where you would like this email to be sent.

Also, directly underneath the line which reads ".Attachments.Add ActiveWorkbook.FullName", you can enter additional attachments to add to the email. Sample code for this is ".Attachments.Add ("C:\myfiles\another_file.xls")" This means that another file on your computer located in the folder C:\myfiles\ will be sent with this email as an attachment; the file's name (including file extension [.xls]) is "another_file.xls"

Where to install the macro:  Module

Email Current Workbook & or Other Attachments

Sub Send_Email_Current_Workbook()

Dim OutApp As Object
Dim OutMail As Object

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "JOHNDOE@TEST.COM"
.CC = "ADD TEXT HERE"
.BCC = "ADD TEXT HERE"
.Subject = "ADD TEXT HERE - Subject"
.Body = "ADD TEXT HERE"
.Attachments.Add ActiveWorkbook.FullName

.Send
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub










How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.


Excel Forum