LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Emailing Workbook bart Excel Discussion (Misc queries) 1 November 5th 07 08:05 PM
emailing tabs from a workbook N Herwerden Excel Worksheet Functions 1 October 3rd 06 08:32 PM
emailing a worksheet from a workbook matmich Excel Discussion (Misc queries) 1 February 15th 06 10:08 PM
Emailing a workbook Jmmac04 Excel Discussion (Misc queries) 0 November 22nd 05 05:20 PM
Emailing a workbook with links GuinevereP Excel Worksheet Functions 2 April 7th 05 12:28 AM


All times are GMT +1. The time now is 02:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"