ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Override protected sheet message? (https://www.excelbanter.com/excel-programming/448228-override-protected-sheet-message.html)

Robert Crandal[_2_]

Override protected sheet message?
 
My sheet is "protected". The user is only allowed to select
locked or unlocked cells. If a user tries to double click on any cell
or change data, Excel shows the following message box:

"The cell or chart that you are trying to change is protected and
therefore read-only."

Does anyone know if it's possible to override this default message
box? It would be nice if I could display my own custom message
box, or run my own subroutine if a user tries to change data on a
protected sheet. I doubt it's possible, but I just want to check if
anyone here knows how to do this??

Thank you!

Robert



GS[_2_]

Override protected sheet message?
 
You can trap the user double-clicking cells in the
Worksheet_BeforeDoubleClick event. Here, you can display your own
message and cancel Excel's notification message (Cancel = True).

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



GS[_2_]

Override protected sheet message?
 
GS has brought this to us :
You can trap the user double-clicking cells in the
Worksheet_BeforeDoubleClick event. Here, you can display your own message and
cancel Excel's notification message (Cancel = True).


Note, however, that this approach doesn't trap if the user presses the
F2 key. Use Application.OnKey to enable/disable this shortcut while
your app is running...

At startup:
Application.OnKey "{F2}", "" '//disable
OR
Application.OnKey "{F2}", "TrapCellEditing" '//run your code

...and be sure to reset it at shutdown...

Application.OnKey "{F2}" '//reset to normal behavior

In your Worksheet_BeforeDoubleClick event you can redirect to the same
procedure...

Cancel = True: Call TrapCellEditing

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



Robert Crandal[_2_]

Override protected sheet message?
 
"GS" wrote:

You can trap the user double-clicking cells in the
Worksheet_BeforeDoubleClick event. Here, you can display your own
message and cancel Excel's notification message (Cancel = True).


Outstanding! Thanks again for your expertise Garry!



GS[_2_]

Override protected sheet message?
 
Robert Crandal has brought this to us :
"GS" wrote:

You can trap the user double-clicking cells in the
Worksheet_BeforeDoubleClick event. Here, you can display your own message
and cancel Excel's notification message (Cancel = True).


Outstanding! Thanks again for your expertise Garry!


Always happy to help, Robert!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion




All times are GMT +1. The time now is 08:52 AM.

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