Disable ESC to exit full screen mode

NDMDRB

Board Regular
Joined
Jun 20, 2016
Messages
164
Office Version
  1. 2016
Platform
  1. Windows
Hello everyone,
I have below macro to view the workbook full screen, i'm just wondering if there is any way to not allow the user to exit full screen using "ESC", unless he use another macro to exit the full screen mode

Sub FullScreen_All()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Activate
With ActiveWindow
.DisplayHeadings = False
.DisplayGridlines = False
End With
Next ws
For Each ws In ActiveWorkbook.Worksheets
Application.DisplayFormulaBar = False
Application.DisplayFullScreen = True
Next ws
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
.
Paste this code into a Routine Module:
Code:
[COLOR=#000000]Sub NoChange()[/COLOR]
[COLOR=#000000]i = 0 ' does nothing, used by NoEsc macro[/COLOR]
[COLOR=#000000]End Sub[/COLOR]
[COLOR=#000000][FONT='inherit']
Sub NoEsc()
Application.OnKey "{ESC}", "NoChange"
' Goes to procedure NoChange if escape key hit
End Sub[/FONT][/COLOR]
[COLOR=#000000][FONT='inherit']
Sub YesEsc()
Application.OnKey "{ESC}"
' Turns on the keyboard escape key.
End Sub[/FONT][/COLOR]

In the ThisWorkbook module paste this code:

Code:
Private Sub Workbook_Open()
     Call NoEsc
End Sub
     



Private Sub Workbook_BeforeClose(Cancel As Boolean)
     Call [COLOR=#000000][FONT='inherit']YesEsc[/FONT][/COLOR]
End Sub
 
Last edited:
Upvote 0
Also, you can dispense with the procedure NoChange by setting the argument for Procedure to an empty string ("")...

Code:
[COLOR=#000000][FONT='inherit']Sub NoEsc()
    Application.OnKey "{ESC}", ""
End Sub[/FONT][/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,485
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top