Ken,
After reading your reply I started looking into the other suggestions you
made and I found the following example of using an API timer in VBA (it's
from C. Pearsons very helpful site for excel VBA tips.)
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''''''''''''
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long
Public TimerSeconds As Single
Sub StartTimer()
TimerSeconds = 20 ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub
Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
'
' The procedure is called by Windows. Put your
' timer-related code here.
'
MsgBox "timed event" '------------------ I added this line
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''
This seemed to work great until I decided to test what would happen if the
timer was started multiple times. I was pleased to see that the message I
had triggering every 20 seconds started triggering multiple times in a 20
seconds period, However it then didn't matter how many times I ran the
EndTimer sub the TimerProc sub kept running, even if Outlook was closed (only
managed to stop it by deleting TimerProc sub from the module and letting
Outlook crash)
Would a 3rd party timer in a userform be likely to have a similar issue or
not?
[Pre Posting Edit--- reading back this text before posting, it has occurred
to me that the issue above may be caused because TimerID is the same for each
case? If so how could I vary it without varying the TimerSeconds?]
So it seems I'm back to task items with reminders for the moment as I can
have multiple 'timers' set at once.
As the timer is just to send a reminder email it doesn't really need to be
at a precise time just approximately 20mins after first email if second is
not received yet. Not sure if that is what you meant by 'granularity of 1
minute'...
This bit of code...
''''''''
Private Sub Application_Reminder(ByVal Item As Object)
If Item.Subject = "Auto Recs Reminder" Then
'------------------My code here---------------
Item.Delete
End If
End Sub
''''''''
Does prevent the Reminder from showing (although you do notice it try to
show) and does, to my mild surprise, delete the TaskItem (I thought it might
just delete the reminder attached to the task.) It does beep though so I will
have to disable the sound when setting the reminder as you suggest.
Again thank you Ken for all your help, before your first reply I did not
even have a clue how to get started with Outlook programming (apart from
coming here to ask ;-) )
"Ken Slovak - [MVP - Outlook]" wrote:
Well, those are the ways I know of to do a timer sort of thing.
You could I suppose set task reminders but those might not have the
granularity you might need. You can only use a granularity of 1 minute. You
would the have to catch the reminder firing and cancel the display of the
reminder plus dismissing it and then deleting the task so the user won't see
it. It might take some experimentation to try to get the reminder canceled
without showing it or playing a reminder sound, although that can be
disabled when you set the reminder.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Damon" wrote in message
...
Ken,
Thank you again for the reply..
I do not have VB 6 installed and this project does not otherwise use a
userform, I could look into calling Win32 API's - although I haven't done
this type of thing before. I have used system information before
(usernames,
logon names) in VBA so I can probably find how to get the system time and
I
would be able to use that.
I have been experimenting with .DeferredDeliveryTime but have had some
flaky
results. At first I thought this was just due to the different 'time' on
my
PC and the mail server, but I also managed to end up with deferred emails
that never sent.
I also have been seeing suggestions to use task reminders for triggers but
have not found an example yet.
Damon