Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Trapping Excel's shutdown

G'day,


I need some help with Excel 5.0, here's my predicament. I am customising Excel with various macros and dialogs (all written in PERSONAL.XLS so that the custom code takes over from startup of Excel) but when exiting Excel I am having trouble duplicating Excel's behaviour. When you choose to exit the application by double clicking the system box in the top left of the window, Excel asks you whether you want to save any of the workbooks that are currently open and unsaved. The options you have are Yes, No and Cancel and selecting Cancel cancels the shutdown of Excel and returns you to the active workbook. Can I duplicate this behaviour with my own macro? The only thing I seem to be able to do when a user closes Excel with the system icon (choosing File-Exit is not a problem as I can substitute my own macro for the Exit menu item) is to put code in the Auto_Close() macro that Excel triggers when exiting. The problem though is that I can't see a way of stopping Excel from terminating from here if a user selects Cancel on my custom message box asking if they want to save an unsaved workbook. Any ideas? Can you trap the clicking of the system icon at all?


Thanks for any help.


Daniel


Comments

  • MozMoz Member Posts: 32
    : G'day,


    : I need some help with Excel 5.0, here's my predicament. I am customising Excel with various macros and dialogs (all written in PERSONAL.XLS so that the custom code takes over from startup of Excel) but when exiting Excel I am having trouble duplicating Excel's behaviour. When you choose to exit the application by double clicking the system box in the top left of the window, Excel asks you whether you want to save any of the workbooks that are currently open and unsaved. The options you have are Yes, No and Cancel and selecting Cancel cancels the shutdown of Excel and returns you to the active workbook. Can I duplicate this behaviour with my own macro? The only thing I seem to be able to do when a user closes Excel with the system icon (choosing File-Exit is not a problem as I can substitute my own macro for the Exit menu item) is to put code in the Auto_Close() macro that Excel triggers when exiting. The problem though is that I can't see a way of stopping Excel from terminating from here if a user selects Cancel on my custom message box asking if they want to save an unsaved workbook. Any ideas? Can you trap the clicking of the system icon at all?


    : Thanks for any help.


    : Daniel
    :
    :
    :
    Daniel -

    I'm not that familiar with the specifics of Excel 5, but are you saying that the Auto_Close event (I assume the equivalent of the Before_Close event in later version) doesn't have "Cancel as Boolean" parameter ... ie. Workbook_AutoClose(Cancel as Boolean)? If it doesn't, I think you're out of luck! The change in later versions allows us to capture the event BEFORE it occurs, whereas it seems that version 5 accepts it has already happened.

    Of course .... I could be wrong!
    Moz.

  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    _________ < http://forcoder.org /> free ebooks and video tutorials about // C# C Scratch Perl R Swift C++ PHP PL/SQL Assembly Java JavaScript Delphi Go Visual Basic .NET MATLAB Python Ruby Objective-C Visual Basic Scala Clojure Scheme Logo Ada VBScript Lisp F# Prolog FoxPro Awk Rust Fortran COBOL Lua LabVIEW ABAP Kotlin Transact-SQL Apex Crystal D Alice Erlang ML Hack Julia Bash Dart SAS // _

Sign In or Register to comment.