WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE and Outlook
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Outlook Quit Event


Question:

I noticed Outlook doesn't seem to like this event I was experimenting with. My version is Outlook 10.0.0.2627 however the "Quit" event is listed in the Object Browser.
#DefineSubRoutine OutlookQuitRoutine()
   Message("Outlook Quitting", "Subroutine Initiated")
   Return
#EndSubRoutine

objOutlook = ObjectOpen("Outlook.Application")
oln = objOutlook.GetNameSpace("MAPI")
oln.logon("", "", 0, 1)
;
OutlookApp = oln.application
Message("Outlook Version", OutlookApp.version)
ClipPut(OutlookApp.version)
;
objecteventadd(OutlookApp, "Quit", "OutlookQuitRoutine")  ;<-- 1752 Object does not support events...
;
;foreach Folder in oln.Folders
;   message("Debug", Folder.name)
;   forEach SubFolder in Folder.Folders
;      display(1, "SubFolder", SubFolder.name)
;   next
;next
;
oln.application.quit
oln   = 0
;
Exit

I did some poking around in my Outlook help file and found...

Quit Event
See Also Applies To Example Specifics 
Occurs when Microsoft Outlook begins to close. This event is not available in VBScript.

Sub object_Quit()

object An expression that evaluates to an Application object.

Example
This example displays a farewell message when Microsoft Outlook exits. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Outlook.

Dim WithEvents myOlApp As Outlook.Application

Sub Initialize_handler()
Set myOlApp = CreateObject("Outlook.application")
End Sub

Private Sub myOlApp_Quit()
MsgBox "Goodbye, " & Application.GetNamespace("MAPI").CurrentUser
End Sub
So I assume that this isn't a Winbatch Issue ?

Answer:

That is correct. It is not a WB issue.
Article ID:   W17131
File Created: 2007:07:03:14:28:26
Last Updated: 2007:07:03:14:28:26