Quit event code - 2007

Status
Not open for further replies.
Outlook version
Outlook 2007
Email Account
Exchange Server
Thanks for the incredible help I've received here, usually lurking through the years of great stuff here. Here's something that I expect will be easy but I'm floundering. If it's not simple, it's okay, this is not really important to me.

I want to intercept Outlook shutdown if there are windows open (emails, reminders) and challenge myself with a yes/no whether to indeed shutdown, like it does when you have "semi-deleted" items, or items that have changed since opening (and emails that have an attachment open, so it prompts you before closing the email). Maybe I'll have a yes/no/cancel msgbox for each active window found, stating its .Name. So I started off in ThisOutlookSession with

Dim olApp As Outlook.Application

Private Sub Application_Quit()
Dim olItems As Outlook.Items, olItem As Object, i As Integer

For Each olItem In olItems 'breakpoint on this line
Next

End Sub

thinking maybe what I really want is

for each Explorer in olApp

or

for each Window in olApp

However the breakpoint in the Quit event only flashes for a second, and then Outlook closes anyway.

1. I request to close OL07 with File/Exit

2. It asks whether to permanently delete Deleted Items

3. I click yes

4. The breakpoint line lights up as though I'll get debug control over execution.

5. A half a second later Outlook disappears and OUTLLOOK.EXE disappears from XP task list.

A. Is Application_Quit() the place to do this?

B. Is there a "collection" of open windows that I can For Each?

C. Can I stop the Quit even? I don't see a "Cancel" boolean, for one thing!
 
Outlook version
Outlook 2007
Email Account
Exchange Server
Thanks, but no good. The MS article actually describes exactly what I'm doing, but even does so incorrectly (it goes in ThisOutlookSession, not a class module). Oh, well, no biggie.
 
Status
Not open for further replies.
Top