ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   On close and before save events. (https://www.excelbanter.com/excel-programming/312505-close-before-save-events.html)

austin

On close and before save events.
 
Hello

I have a workbook, when the user exits the workbook I want
it to hide (using veryhidden) all the worksheets.
When a new user opens the workbook I want to make them
select enable macros or nothing but a blank worksheet will
show.

This all I can do. The problem I face is if I add the hide
worksheets code to the before close event. If a user saves
and then tries to close the book the macro runs and then
excel asks the usual, changes have been made do u want to
save. And so the user has to save again. If I attach the
code to before save, the user may not want to close the
workbook so I don't want the macro to run.

Is there a way around this?

Austin

Tom Ogilvy

On close and before save events.
 
In the beforeclose event, turn off events, hide the sheets, save the
workbook, Turn events back on, continue closing. I haven't tested it
recently, but I expect that you shouldn't get prompted since you just saved
the workbook (which you need to do anyway if you want the sheets to be
hidden).

--
Regards,
Tom Ogilvy

"Austin" wrote in message
...
Hello

I have a workbook, when the user exits the workbook I want
it to hide (using veryhidden) all the worksheets.
When a new user opens the workbook I want to make them
select enable macros or nothing but a blank worksheet will
show.

This all I can do. The problem I face is if I add the hide
worksheets code to the before close event. If a user saves
and then tries to close the book the macro runs and then
excel asks the usual, changes have been made do u want to
save. And so the user has to save again. If I attach the
code to before save, the user may not want to close the
workbook so I don't want the macro to run.

Is there a way around this?

Austin





All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com