Macro: Mail Workbook

Today’s macro is helpful if you send a lot of excel files via email. Running the macro will create a new Microsoft Outlook email with the last saved version of the open workbook. By default the email will not be addressed to anyone, the subject of the new email will be the name of workbook, and the body will be “See attached.” These settings can be customized by editing the macro code below. It might be helpful to change the to: line to the email address of your supervisor or someone you send your spreadsheets to often.

Once you add this macro all you will need to do is run the macro (the macro will be named Mail_Workbook).

Excel Macro Code:

Sub Mail_Workbook()
 Dim OutApp As Object
 Dim OutMail As Object

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

 On Error Resume Next
 With OutMail
 .To = ""
 .CC = ""
 .BCC = ""
 .Subject = ActiveWorkbook.Name
 .body = "See attached."
 .Attachments.Add ActiveWorkbook.FullName
 .Display
 End With
 On Error GoTo 0

 Set OutMail = Nothing
 Set OutApp = Nothing
End Sub

View the full listing of VBA macros.

Advertisements

2 thoughts on “Macro: Mail Workbook

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s