-
Aug 22nd, 2012, 07:39 AM
#1
Thread Starter
Junior Member
[RESOLVED] Autogeneration of an email dependant on time criteria
Hi guys,
I have set up a windows scheduler even to open a specific file every friday at 9.30am.
I now would like to set up a workbook_open event which generates an email when the scheduler opens the file.
I dont want the email to generate every time the work book is open.
Does anyone have any sample code for me? I am interested in determining time workbook opened and day, and I am also unsure of the code required to send an email.
Any assistance would be much appreciated:
*update*
Got this far.
I want the email to be sent only if the workbook is opened between the times 9:25 and 9:35am . I have entered these times into the worksheet as ranges in cells: LTime (9:25) and UTime (9:35) . Formatted them as times.
Generation of email works. Only remaining issue is that the statement:
If LTime > dTime > UTime keeps on evaluating to false.
Does anyone know why this keeps on evaluating to false.
Sub Workbook_Open()
Dim dTime As Date
Call Definitions
dTime = TimeValue(Now)
Dim LTime As Date
Dim UTime As Date
LTime = wsConsole.Range("LTime")
UTime = wsConsole.Range("UTime")
LTime = TimeValue(LTime)
UTime = TimeValue(UTime)
If LTime > dTime > UTime Then
Call Send_Email_Using_Keys
Else: Call Open_Book
End If
End Sub
Thanks
Last edited by InderpalHothi; Aug 22nd, 2012 at 10:31 AM.
Reason: update
-
Aug 22nd, 2012, 08:38 AM
#2
Thread Starter
Junior Member
Re: Autogeneration of an email dependant on time criteria
Last edited by InderpalHothi; Aug 22nd, 2012 at 10:32 AM.
-
Aug 23rd, 2012, 04:57 AM
#3
Re: Autogeneration of an email dependant on time criteria
try more like
Code:
If Time > "9:25" And Time < "9:35" Then
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 23rd, 2012, 07:55 AM
#4
Thread Starter
Junior Member
Re: Autogeneration of an email dependant on time criteria
cheers, problem sorted.
Used :
If Utime>dTime and Dtime>Ltime
etc
-
Aug 23rd, 2012, 04:04 PM
#5
Re: Autogeneration of an email dependant on time criteria
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|