Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Help needed with automated emailing of workbook
Hello,
I thought I had solved a previous problem that I had with sending an email when a value in a range got above a certain number, but I haven't as it seems to send it out regardless. I am trying to write the code to put in the workbook's beforeclose, but my code is very rusty, and I am not sure of how to get it to work properly: Private Sub Workbook_BeforeClose(Cancel As Boolean) 'Declare variables Dim shtSummary As Worksheet Dim rngChange As Range Set shtSummary = Application.Workbooks("xxx.xls").Worksheets("Summa ry") Set rngChange = shtSummary.Range("M1:M12") On Error GoTo EndMacro If rngChange 10 Then GoTo sendeMail sendeMail: '(with Thanks to Ron de Bruin) 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 = "(me)" .CC = "" .BCC = "" .Subject = "TEST TEST TEST" .Body = "Site(s) in this contract appear over budget. Please verify over costs are justified & appropriate documentation completed including EOT,variations & additional works." .Attachments.Add ActiveWorkbook.FullName .Send End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing EndMacro: End Sub Can someone help here please? Basically I am trying to say for each value in the range, if the value is greater than 10 then send an email. Thanks! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Emailing Workbook | Excel Discussion (Misc queries) | |||
emailing tabs from a workbook | Excel Worksheet Functions | |||
emailing a worksheet from a workbook | Excel Discussion (Misc queries) | |||
Emailing a workbook | Excel Discussion (Misc queries) | |||
Emailing a workbook with links | Excel Worksheet Functions |