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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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