excel-training-advanced courses - macro automate emailing spreadsh
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel Training and help » excel-training-advanced courses - Macro to automate e-mailing of spreadsheet

excel-training-advanced courses - Macro to automate e-mailing of spreadsheet

resolvedResolved · Low Priority · Version Standard

replyReply Wed 19 Dec 2007, 17:03Delegate Kevin said...

Kevin has attended:
Excel Advanced course
Excel VBA Intro Intermediate course

Macro to automate e-mailing of spreadsheet

I want to add a button within a spreadsheet which will open outlook and attach the completed spreadsheet. how do I do that?

For upcoming training course dates see: Pricing & availability

replyReply Fri 4 Jan 2008, 12:33Trainer Stephen said...

RE: Macro to automate e-mailing of spreadsheet

Hi Kevin

Thankyou for your question

If you create you button on the tool bar and set it to run the following code, you should find it works OK, although we my need to tweak it further to meet your specific requirements.

In particular the recipient and subject are hard coded and you might want to repalce them with variables so the user can define them at run time

Public Sub sendemail()

Dim Outlook As Object
Dim NameSpace As Object
Dim MailItem As Object
Dim recipient As String

recipient = "bob@acompany.com"

Set Outlook = CreateObject("Outlook.Application")
Set MailItem = Outlook.Createitem(0)

With MailItem
.Subject = " Test Email"
.Recipients.Add recipient
.body = "Workbook"
.send
End With

End Sub

 

Excel tip:

Quickly select a block of data

To quickly select a block of data make sure your active cell is somewhere whithin the block of data and then press Ctrl+* or Ctrl+Shift+8.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard