Hi Bryan,
Thanks for getting back to me so quickly on this one. To satisfy your curiosity, the red items of code you pointed out are for the remote possibility of anyone opening this sheet and setting off only the sendIt module (I code paranoid Im afraid). The page you pointed out was kind of useful, but there still seems to be a problem with cancelling ontime events.
This line of code.....
Application.OnTime sTimer, "sendIt", , False
...threw an error as soon as I tried to use it (Method ontime of object application failed). I just have a nasty feeling that if the Ontime isn't cancelled it will schedule itself to run again and again. Its only the saturday and sunday routines I'm concerned about as the monday-friday routine is simple. Any ideas as to why this error is being thrown? This is how the code looks now:
Sub evalDay()
sTimer = TimeValue("09:00:00")
If WeekDay(Now) = 7 Then
saturday
ElseIf WeekDay(Now) = 1 Then
sunday
Else
Application.OnTime sTimer, "sendIt"
End If
End Sub
------------------------------------------------------------------------
Sub saturday()
Application.OnTime sTimer, "sendIt", , False
'****Cancel the daily routine - Error
Application.OnTime Now + TimeValue("23:59:59"), "sunday"
sunday
End Sub
-------------------------------------------------------------------------
Sub sunday()
Application.OnTime sTimer, "sendIt", , False
'*****Cancel the daily routine - Error
If Time = "23:59:59" Then Application.OnTime Now + TimeValue("8:59:59"), "sendIt"
End Sub
-------------------------------------------------------------------------
Sub sendIt()
Set oApp = CreateObject("outlook.application")
Set oItem = oApp.createItem(olMailItem)
oItem.attachments.Add ("attachment_Path")
oItem.To = "someone@somedomain.com"
oItem.Body = "Message content"
oItem.Send
Set oApp = Nothing
End Sub
------------------------------------------------------------------------
Much appreciated
Joe
Bookmarks