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