none
Cancel Outlook Quit event via vba RRS feed

  • Question

  • Hi I want to display a message when the user closes Outlook. This message will ask the user if he wishes to close Outlook  with a Yes/No response.

    Problem: In Outlook vba, I am able to cancel the Item_Send event (through a "Cancel" referenced variable passed as boolean)  but I cant seem to find any "Cancel" referenced variable being passed in Outlook Quit event to stop Outlook Quit.


    • Edited by DC787 Thursday, February 2, 2017 4:58 AM
    Thursday, February 2, 2017 4:56 AM

Answers

  • Hello,

    You may try to handle the Close event of the Explorer class which is fired when an explorer is being closed. So, you may check out the Explorers.Count property to be sure there is no other explorers shown. The Close event is also available for inspectors. The Cancel parameter of the Close event allows to cancel the default action, you just need to set it to true. Basically you check for any other Outlook windows (explorer/inspector) displayed when the explorer window is going to be closed, if yours is the last Outlook will be shutdown. In that case you can cancel the action by setting the Cancel parameter to true.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Proposed as answer by Chenchen LiModerator Friday, February 3, 2017 1:39 AM
    • Marked as answer by DC787 Tuesday, September 5, 2017 8:53 PM
    Thursday, February 2, 2017 6:12 AM