Disable ESC to exit full screen mode

NDMDRB

Board Regular
Joined
Jun 20, 2016
Messages
158
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
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,865
.
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:

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,406
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:

Watch MrExcel Video

Forum statistics

Threads
1,123,481
Messages
5,601,918
Members
414,482
Latest member
morkar

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
Top