A circular solution

G

George Hester

Please take a look at this article:

OL2002: ItemAdd Event Doesn't Run in Some Scenarios
http://support.microsoft.com/kb/290653/EN-US/

In Method 1 you will see a link to Create a Solution That Runs at a Specific
Time Interval the link to which is the page where you are reading this.

Uhm any chance this article exists?
 
M

Michael Bauer [MVP - Outlook]

Add a module (*.bas) to your project and insert this:

' <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>

And this into ThisOutlookSession:

Private Sub Application_Startup()
' Starts the timer with an interval of 60,000 ms (=1 minute)
EnableTimer 60000, Me
End Sub

Public Sub Timer()
' This method will be called by the timer
' So here's the place for your code
End Sub

Private Sub Application_Quit()
' IMPORTANT: The timer must be disabled explicitly if you quit Outlook.
DisableTimer
End Sub

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Keep your Outlook categories organized!
http://www.shareit.com/product.html?productid=300120654&languageid=1
(German: http://www.VBOffice.net/product.html?pub=6)


Am Tue, 23 Jan 2007 22:16:45 -0500 schrieb George Hester:
 
G

George Hester

Hi Michael your last function DisableTimer() can that be a Subroutine as you
have not typed it?
 
G

George Hester

yes I put it in. But if you look at your last function DisableTimer you
will see that you do not define the function such that

Public Function DisableTimer() As ???

So that is why I asked if that could just be a Public Sub also because you
do not assign anything to DisableTimer in the function. Maybe

Public Function DisableTimer() As Boolean
If hEvent = 0 Then
DisableTimer = False
Ecit Function
End If
KillTimer 0&, hEvent
hEvent = 0&
DisableTimer = True
End Function

or just make it a subroutine since we are not interested in a return value.
Or would there be some other reason for using this as a function?
 
D

Dan Mitchell

George Hester said:
OL2002: ItemAdd Event Doesn't Run in Some Scenarios
http://support.microsoft.com/kb/290653/EN-US/

In Method 1 you will see a link to Create a Solution That Runs at a
Specific Time Interval the link to which is the page where you are
reading this.

Uhm any chance this article exists?

Back to the original posting -- yup, the "method 1" link has a typo.
Searching for that will find it, but they just wanted the next KB article
along:

http://support.microsoft.com/kb/290654/EN-US/

-- dan
 
G

George Hester

I think they changed the link. This new one isn't circular but leads to
nothing associated with the article. That's OK Michael gave me an example.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top