Thank you! Will definitely check this out.
[snip]
[Copied here since websites tend to disappear sometimes ... <g>.]
*************************************
2007-12-19 05:40:58
(
http://www.vboffice.net/sample.html?mnu=2&pub=6&lang=en&smp=4&cmd=showitem)
API Timer
Author: Michael Bauer Homepage
Date: 18.01.2006 Accessed: 2227
Description
A timer is useful if you want to start a function in a short interval.
Because there's no Timer control in VBA available you have to use the
Win32 API instead.
This sample shows such an API timer, and how to receive its event:
Create a standard module, here called 'modTimer' and copy the code
into it, and create a public method called 'Timer' in
'ThisOutlookSession'. That method will be called by the timer. The
timer is enabled in Application_Startup, that is when Outlook starts,
with an interval of 60000 milliseconds (= 1 minute).
Please note: you must disable the timer before Outlook quits!
Private Sub Application_Startup()
EnableTimer 60000, Me
End Sub
Public Sub Timer()
' Called from the timer
End Sub
Private Sub Application_Quit()
DisableTimer
End Sub
' <Modul: modTimer.bas>
Option Explicit
Private Declare Function SetTimer Lib "user32.dll" (ByVal hwnd As
Long, _
ByVal nIDEvent As Long, ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32.dll" (ByVal hwnd As
Long, _
ByVal nIDEvent As Long) As Long
Const WM_TIMER = &H113
Private hEvent As Long
Private m_oCallback As Object
Public Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long _
)
If uMsg = WM_TIMER Then
m_oCallback.Timer
End If
End Sub
Public Function EnableTimer(ByVal msInterval As Long, oCallback As
Object) As Boolean
If hEvent <> 0 Then
Exit Function
End If
hEvent = SetTimer(0&, 0&, msInterval, AddressOf TimerProc)
Set m_oCallback = oCallback
EnableTimer = CBool(hEvent)
End Function
Public Function DisableTimer()
If hEvent = 0 Then
Exit Function
End If
KillTimer 0&, hEvent
hEvent = 0
End Function
' <modTimer.bas>
*************************************