Block the F8 function key

zelarra

Board Regular
Joined
Jan 2, 2021
Messages
70
Office Version
  1. 365
Platform
  1. Windows
Hi guys. I need your help.

In the workbook_open event I have added the following to avoid opening Powershell:

Application.OnKey "%{F12}", ""

Now, on the other hand, I want to prevent the F8 function key being activated so that the user cannot start the selection with the keyboard. I have tried the following, but I can't make it work:

Application.OnKey "{F8}", ""

Can anyone tell me what I am doing wrong?

Thank you so much.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Paste in the THISWORKBOOK module :

VBA Code:
Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.OnKey "{F11}"
End Sub

Private Sub Workbook_Open()
    Application.OnKey "{F11}", ""
End Sub
 
Upvote 0
Solved

VBA Code:
Private Sub Workbook_Open()

    Application.OnKey "{F18}", "DisableF8"

End Sub

In a module:

VBA Code:
Private Sub DisableF8()

Exit sub

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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