Working with Explorer.Close event

Not open for further replies.
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server
I'm trying to get Outlook to do some things when the user closes the application.

I tried using the app.quit event, but that's too late, because by the time it fires, Outlook has already released all of my variables/objects. I need to run my code in an event that fires before that.

I found some (sparse) documentation suggesting to use Explorer.Close() event for that reason. But I don't think the event is firing... or I've set it up wrong?

I declared global variables:
Private WithEvents MyExplorers as Outlook.Explorers
Private WithEvents MyExplorer as Outlook.Explorer.

In Application_Startup, I do:
Set MyExplorers = Application.Explorers
Set MyExplorer = MyExplorers.Item(1)
(And I've verified that it does get set)

Then I created:

Private Sub MyExplorer_Close()

>> This sub never runs. Why not?

(Further: I also created MyExplorers_NewExplorer() to verify that this event was firing. It does.)

I can find very little documentation or examples for the Explorer events.
Any help?

By the way -- the thing I'm ultimately trying to accomplish... While Outlook is running, I have a draft email that I use to log various stuff that I want logged. Before Outlook shuts down, I want it to Send that draft email to me. So have a global MyLog as MailItem, and I need to call MyLog.Send. That's what I want to put in MyExplorer.Close().
You can try to set RequireShutdownNotification in the registry for the VBA Addin, add that key to the Addin with a dword value of 1.

Thanks, Michael. What will that do? I'm guessing; but it doesn't sound like it will cause the Explorer.Close event to fire. Rather, it sounds like maybe it will cause Outlook to stop and wait for me to click a button before it closes?
It just notifies the Addin that Outlook is going to close.
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
N VBA Code Not Working correctly Outlook VBA and Custom Forms 1
T Outlook 365 won't take new working password Using Outlook 0
E Outlook 365 Save Selected Email Message as .msg File - oMail.Delete not working when SEARCH Outlook VBA and Custom Forms 0
Z Outlook 2021 Outlook new emails notification not working Using Outlook 4
A Outlook 365 Outlook (part of 365) now working offline - argh Using Outlook 5
G LinkedIn tab missing in Outlook 365 (but working in OWA) Using Outlook 0
BartH VBA no longer working in Outlook Outlook VBA and Custom Forms 1
S New Email "From" box stopped working Using Outlook 0
R Outlook Working off line Using Outlook 0
H How to Fix 1510-370-1986 Garmin GPS Not Working Outlook VBA and Custom Forms 0
M Outlook 2019 Macro not working Outlook VBA and Custom Forms 0
L Outlook 365 Outlook not working on linux how to solve it Using accounts in Outlook 0
Z OST Stopped working without explanation Using accounts in Outlook 3
Commodore Automatic switch between working offline/online Using Outlook 4
V Outlook 2016 iCloud for Windows - Why no working Calendars and Tasks ? Using Outlook 1
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
G print attachment straight away; working script edit not working Outlook VBA and Custom Forms 0
V Auto-complete stopped working Using Outlook 4
F Searches are not working properly Using Outlook 1
Jennifer Murphy Spam filter not working Using Outlook 13
D Connecting Gmail to Outlook 365 - My Setup not working Using Outlook 2
A Prepending Email Addrs with "Display Name <email>" Has Stopped Working Using Outlook 0
R rules not working - done troubleshooting Using Outlook 0
R Follow up button doesn't working neither the reminders in BCM BCM (Business Contact Manager) 0
A calendar invites sent from Microsoft Outlook to Mac Outlook is not working Using Outlook 2
Z Task Filter Not Working When I add too many criteria Using Outlook 0
D iCloud Add-in not working in Outlook 2013 and Outlook 2016 After Windows Upgrade & iCloud Upgrade Using Outlook 2
bmtjedi Set objApp = Application Not Working in O365-32bit Using Outlook 1
B Outlook 2003 email sending & receiving suddenly stopped working Using Outlook 3
S Outlook Custom Form Scripting only working when clicking on "Run this form" Outlook VBA and Custom Forms 2
K Outlook 2016 - controlling IMAP OST size with Group Policy not working Using Outlook 1
F KB4475563 stops VBS at forms working Outlook VBA and Custom Forms 3
J Copy to calendar function no longer working in outlook 365 Using Outlook 5
D Archive by receive date not working Using Outlook 2
M move to iCloud not working in outlook calendar Using Outlook 12
cricket1001 Shade non-working days in calendar Using Outlook 0
L Outlook 2019 MAC sync error after working for 4 hours Using Outlook 1
A rules not working Using Outlook 2
B Reply and replyall macro is not working Outlook VBA and Custom Forms 1
D Any updates or fixes that would make this code stop working just moving emails to another folder Outlook VBA and Custom Forms 1
V Autocomplete not working on new email account Using Outlook 4
P Two main Outlook gripes: Voting buttons not working externally nor Focused Inbox Using Outlook 1
M email search not working Using Outlook 1
B When working on emails in a certain folder, when I hit reply or reply all, I would like it re always reply all and add an email address to send to Outlook VBA and Custom Forms 3
J Menus not working BCM (Business Contact Manager) 7
N Syncing my inbox not working for certain types of mail Using Outlook 9
A rules (flags) not working Using Outlook 7
P Outlook search is not working at all for Calendar & Tasks Using Outlook 7
D Delay Send not working Using Outlook 3
B Search function in Office 365 has stopped working Using Outlook 3

Similar threads