TheAntiGates
08-13-2013, 08:40 AM
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. Anyway to to get cranking 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 Subwith the aim of perhaps going
for each Explorer in olApp
or
for each Window in olApp
I'm just spitballing at this point; I'm weak on these objects.
However using the compiled code as shown the breakpoint in the Quit event only flashes for a second, and then Outlook closes anyway.
A. I request to close OL07 with File/Exit
B. It asks whether to permanently delete Deleted Items
C. I click yes
D. The breakpoint line lights up as though I'll get debug control over execution.
E. A half a second later Outlook disappears and OUTLLOOK.EXE disappears from XP task list.
So my questions are:
1. Is Application_Quit() the place to do this?
2. Can I EVEN stop the Quit anyway? I don't see a "Cancel" boolean, for one thing!
3. Is there a "collection" of open windows that I can For Each upon?
Thanks.
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 Subwith the aim of perhaps going
for each Explorer in olApp
or
for each Window in olApp
I'm just spitballing at this point; I'm weak on these objects.
However using the compiled code as shown the breakpoint in the Quit event only flashes for a second, and then Outlook closes anyway.
A. I request to close OL07 with File/Exit
B. It asks whether to permanently delete Deleted Items
C. I click yes
D. The breakpoint line lights up as though I'll get debug control over execution.
E. A half a second later Outlook disappears and OUTLLOOK.EXE disappears from XP task list.
So my questions are:
1. Is Application_Quit() the place to do this?
2. Can I EVEN stop the Quit anyway? I don't see a "Cancel" boolean, for one thing!
3. Is there a "collection" of open windows that I can For Each upon?
Thanks.