isladogs
MVP / VIP
- Local time
- Today, 02:36
- Joined
- Jan 14, 2017
- Messages
- 19,021
Hi
I've been working on a kiosk type form following a question from another forum user.
As part of this, I'm trying to disable selected key combinations in a form using the Form_KeyDown (KeyCode As Integer, Shift As Integer) event.
I have set the form KeyPreview = Yes
Specifically I want to block Alt+Tab & the use of the Windows key e.g. Win+E
For example, I know that code like the following will work
'disable key E
'disable tab key
'disable Alt key
'another way of disabling Alt key
However combining to block the Alt+Tab combination doesn't work:
Similarly this doesn't work:
Similarly I can't find any way of detecting the Windows key let alone blocking it
Are blocking either of these possible using VBA or failing that using Windows APIs
Can anyone help with this
I've been working on a kiosk type form following a question from another forum user.
As part of this, I'm trying to disable selected key combinations in a form using the Form_KeyDown (KeyCode As Integer, Shift As Integer) event.
I have set the form KeyPreview = Yes
Specifically I want to block Alt+Tab & the use of the Windows key e.g. Win+E
For example, I know that code like the following will work
'disable key E
Code:
If KeyCode=vbKeyE Then KeyCode=0
'disable tab key
Code:
If KeyCode=vbKeyTab Then KeyCode=0
'disable Alt key
Code:
If KeyCode = vbKeyMenu Then KeyCode=0
'another way of disabling Alt key
Code:
If Shift = acAltMask Then KeyCode=0
However combining to block the Alt+Tab combination doesn't work:
Code:
If Shift = acAltMask Then
If KeyCode = vbKeyTab Then
Debug.Print "ALT + TAB keys pressed"
KeyCode=0
End If
End If
Similarly this doesn't work:
Code:
If Shift = acAltMask And KeyCode = vbKeyTab Then
Debug.Print "ALT + TAB keys pressed"
KeyCode=0
End If
Similarly I can't find any way of detecting the Windows key let alone blocking it
Are blocking either of these possible using VBA or failing that using Windows APIs
Can anyone help with this