ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   disable shortcut keys (https://www.excelbanter.com/excel-programming/390888-disable-shortcut-keys.html)

Chris Wilkinson

disable shortcut keys
 
Hi,

I need to disble all Excel's shortcuts such as ctrl+c, etc. I there an
easier way than looping through all the combinations of alt, ctrl, shift and
each key combination and disabling them with application.onkey?

thanks
Chris

Ron de Bruin

disable shortcut keys
 
Saved from a old post

You can use Onkey (see VBA Help)

Try this two macro's

Sub UIT()
Dim K, Key, Key2, i As Integer
On Error Resume Next


For Each Key In Array("+", "^", "%", "+^", "+%", "^%", "+^%")


K = Array("{BS}", "{BREAK}", "{CAPSLOCK}", "{CLEAR}", "{DEL}", _
"{DOWN}", "{END}", "{ENTER}", "~", "{ESC}", "{HELP}", "{HOME}", _
"{INSERT}", "{LEFT}", "{NUMLOCK}", "{PGDN}", "{PGUP}", _
"{RETURN}", "{RIGHT}", "{SCROLLLOCK}", "{TAB}", "{UP}")


For Each Key2 In K
Application.OnKey Key & Key2, ""
Next Key2


For i = 0 To 255
Application.OnKey Key & Chr$(i), ""
Next i


For i = 1 To 15
Application.OnKey Key & "{F" & i & "}", ""
Application.OnKey "{F" & i & "}", ""
Next i
Next
Application.OnKey "{PGDN}", ""
Application.OnKey "{PGUP}", ""
End Sub


Sub AAN()
Dim K, Key, Key2, i As Integer
On Error Resume Next


For Each Key In Array("+", "^", "%", "+^", "+%", "^%", "+^%")


K = Array("{BS}", "{BREAK}", "{CAPSLOCK}", "{CLEAR}", "{DEL}", _
"{DOWN}", "{END}", "{ENTER}", "~", "{ESC}", "{HELP}", "{HOME}", _
"{INSERT}", "{LEFT}", "{NUMLOCK}", "{PGDN}", "{PGUP}", _
"{RETURN}", "{RIGHT}", "{SCROLLLOCK}", "{TAB}", "{UP}")


For Each Key2 In K
Application.OnKey Key & Key2
Next Key2


For i = 0 To 255
Application.OnKey Key & Chr$(i)
Next i


For i = 1 To 15
Application.OnKey Key & "{F" & i & "}"
Application.OnKey "{F" & i & "}"
Next i
Next
Application.OnKey "{PGDN}"
Application.OnKey "{PGUP}"
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Chris Wilkinson" wrote in message
...
Hi,

I need to disble all Excel's shortcuts such as ctrl+c, etc. I there an
easier way than looping through all the combinations of alt, ctrl, shift and
each key combination and disabling them with application.onkey?

thanks
Chris




All times are GMT +1. The time now is 09:53 AM.

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