Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

excel-training-advanced courses - macro automate emailing spreadsh

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

ResolvedVersion Standard

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?

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:

Conditional formatting for cells that return text , not picked up by Go to command

If you have tried to format all cells containing text even those that display text as a result of a formula you may have had difficulty. As Go to command with constant selected does not pick up formulas that result in text.

Then try this. Select the range the formula cells appear in on your sheet. Format, select Conditional Formatting menu. In the dialog box under Condition 1, select "Formula Is" from drop down. Next to it in the Formula Box, enter the formula =Istext(A1. Click Format button , choose desired formatting settings and click OK. To go ahead and apply the conditional formatting click OK to accept

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.