Hallo,
okidoki sähe dann so die Richtung aus...
In Dein ThisOutlookSession Modul mit dem Event:
Option Explicit
Private WithEvents objInspectors As Outlook.Inspectors
Private Sub Application_Quit()
Set objInspectors = Nothing
End Sub
Private Sub Application_Startup()
Set objInspectors = Application.Inspectors
End Sub
Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
'....
If Antwort = vbYes Then
Edit_Termin 'Mokro zur Bearbeitung des termins
Call StartTimer(probjInspector:=Inspector) '//<-----hier der Timer-Call.....
End If
'....
End Sub
Dann in ein Standard-/Allg. Modul (Einfügen >>> Modul):
Option Explicit
Option Private Module
Private Declare Function FindWindowA Lib "user32.dll" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SetTimer Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimer As Long) As Long
Private Declare Function KillTimer Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long
Private Const GC_CLASSNAMEMSOUTLOOK As String = "rctrl_renwnd32"
Private llngHwnd As Long
Private lobjInspector As Inspector
Public Sub StartTimer(ByRef probjInspector As Inspector)
llngHwnd = FindWindowA(GC_CLASSNAMEMSOUTLOOK, vbNullString)
If llngHwnd <> 0 Then
Set lobjInspector = probjInspector
Call SetTimer(llngHwnd, 0&, 5&, AddressOf TimerProc)
End If
End Sub
Private Sub StopTimer()
Call KillTimer(llngHwnd, 0&)
llngHwnd = 0
End Sub
Private Sub TimerProc(ByVal hWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimer As Long)
Call StopTimer
If Not lobjInspector Is Nothing Then
Call lobjInspector.Close(olDiscard) '//<----hier Dein Schließenvorgang '// ggf olSave
Set lobjInspector = Nothing
End If
End Sub
Gruß,
|