Message on screen before close / save

User avatar
Doc.AElstein
BronzeLounger
Posts: 1499
Joined: 28 Feb 2015, 13:11
Location: Hof, Bayern, Germany

Re: Message on screen before close / save

Post by Doc.AElstein »

ErikJan wrote:
28 Dec 2020, 14:27
....what if the user messed-up the content somehow and wants to exit without saving?
As far as I can tell, your latest solution will work if the user exits without saving: If the user exits without saving , then the workbook is as it was before the user opened it. So the warning will still be there, and will appear at the next opening, just as it was on the previous opening

_._____________________________________________________
ErikJan wrote:
28 Dec 2020, 15:47
Right; my problem is that I DO NOT want to show "changes that are only for the file to save". They should remain invisible during close ...
.... so , the bug ( I mean that Microsoft useful "feature" ) in shapes , which prevents sometimes a shape from showing, could be helpful.
I am having difficulty logging in with this account just now.
You can find me at DocAElstein also

User avatar
ErikJan
BronzeLounger
Posts: 1228
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Message on screen before close / save

Post by ErikJan »

For the sake of completeness, here's again the order of events when I open a WB and -in a little more detail- when I Save or Close a WB.
It is interesting to see that the user interaction (dialog prompts) take place after"Auto_Close" but BEFORE "Workbook_BeforeSave".
(The actual moment that that file is saved is between the BeforeSave and AfterSave events as expected).

=== Opening a Workbook ===
WB_Open
WB_Activate
WB_WindowActivate
Auto_Open

=== Saving a Workbook ===
>> If new WB then dialog prompt else >WB_BeforeSave
>> Only if user selects to save then
WB_BeforeSave
WB_AfterSave

=== Closing a Workbook ===
WB_BeforeClose
Auto_Close
>> If changes are pending then dialog prompt else >WB_WindowDeActivate
>> If user selects not to save then >WB_WindowDeActivate
WB_BeforeSave
WB_AfterSave
WB_WindowDeActivate
WB_DeActivate
Last edited by ErikJan on 13 Jan 2021, 09:44, edited 2 times in total.

User avatar
ErikJan
BronzeLounger
Posts: 1228
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Message on screen before close / save

Post by ErikJan »

And that, in turn, means also that if one cannot use the Before- and After-Save events (because of problems with Excel's AutoSave functionality) there's no (simple) way to change the looks of the Workbook before saving and return to the normal look afterwards without the end-user seeing that (as the user prompts take place AFTER the Auto_Close (PS. I edited my previous post to correct for a small mistake)