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.
Thread starter Similar threads Forum Replies Date
K Handling application.quit event Outlook VBA and Custom Forms 8
C Outlook email progress window will not quit Using Outlook 1
M Search quit Using Outlook 1
J [outlook-users] outlook 2007 Sp2: Error message to quit outlook Using Outlook 9
F Outlook process won't end after I quit the program Using Outlook 2
C RSS feeds sometimes quit working Using Outlook 4
J Communicator won't allow Outlook to quit Using Outlook 1
P Outlook 2007 has quit working Using Outlook 2
M Unable to open Outlook. Error: Error have been detected in the files c:user\my name\appdata\local\microsoft\outlook\outlook.pst. quit outlook and mai Using Outlook 1
N Cannot display the folder. There is not enough free memory to run this program. Quit one or more pro Using Outlook 10
N Cannot display the folder. There is not enough free memory to run this program. Quit one or more pro Using Outlook 9
T Calendar quit working months ago Using Outlook 2
P The Microsoft Exchange Administrator has made a change that requires you quit and restart Outlook Exchange Server Administration 7
S Send All emails in Outbox and Quit using VBA Outlook VBA and Custom Forms 3
R Help, Outlook2003 won't quit after call OnDisconnection? Outlook VBA and Custom Forms 3
R Outlook wont .quit Outlook VBA and Custom Forms 4
J Outlook 2010 Outlook/Win7 Client logging Event ID 36887 Using Outlook 0
K Recurring all day annual event Using Outlook 3
P Restore an individual all-day recurring event Using Outlook 2
K VBA BeforeItemMove event create rule to always move to its folder. Outlook VBA and Custom Forms 4
K Working with Explorer.Close event Outlook VBA and Custom Forms 3
F Outlook 2016 call to Stop Timer Event Outlook VBA and Custom Forms 4
D Event ID issues Exchange Server Administration 2
J ItemChange event Outlook VBA and Custom Forms 11
T Outlook 2016 Calendar multiday event display Using Outlook 4
oliv- Treat once an email with the ItemAdd event in a shared mailbox Outlook VBA and Custom Forms 2
M Automatically create event in calendar when task is created Outlook VBA and Custom Forms 1
A UID field in iCal files - unique per-event or per-user or both? Using Outlook 2
D help with Item/Inspector close event Outlook VBA and Custom Forms 1
B on flag message event - create task Outlook VBA and Custom Forms 22
Diane Poremsky Change the All Day Event Default Free/Busy to "Busy" New Slipstick.com Articles 3
C Calendar - Centering an event in Outlook? Using Outlook 1
J Outlook calendar...How to add an event or appointment without a border around it? Using Outlook 9
J Create Calendar Alert Event form Mail Subject line? Using Outlook 4
S Item Add Event fires intermittently Outlook VBA and Custom Forms 3
R Why is a meeting organizer me and not the creator of the event? Using Outlook 1
V Calendar event acting odd Using Outlook 7
G Capture "forward event" ? Outlook VBA and Custom Forms 11
P Change the Outlook.com "from" address for calendar event invites Using Outlook 9
20 Ton Squirrel Detect Application_Startup event completion Outlook VBA and Custom Forms 1
L Outlook 2007 All Day Event Using Outlook 27
I Event listener for deleted items Using Outlook 6
M Save Attachments Event? Using Outlook 0
Commodore Calendar Folder property is missing - Event 27 Using Outlook 11
J Capturing forward event when multiple items are selected Using Outlook 0
P Trying to get 'Calendar Name' to appear like 'Subject' and 'Location' in event Calendar Printing Assistant 0
G What event happens when you open 2 copies of your inbox? Using Outlook 5
D Adding a participant automatically to a calendar event Using Outlook 1
H Changing Organizer of event (for single to total calendar move; long way ) Exchange Server Administration 4
N Combobox in outlook add ons toolbar not firing event on main window resized Using Outlook 3
Similar threads


















































Top