I have the following declaration and function combination which I find very useful. As you see they enable me to detect the state of the Shift and Ctrl keys at the time the macro was called and to change the behaviour accordingly.
However I cannot find any way to enhance this function to detect the state of the Alt key. There is no constant vbKeyAlt.
Is there a way of getting VBA to detect the status of the Alt key?
Thanks.
Jim Brook
JBConsulting
Private Declare Function GetKeyState Lib “user32” (ByVal vKey As Long) As Integer
Public Function jbGetCurrentKeyState(lngKey As Long) As Boolean
Select Case lngKey
Case vbKeyShift
jbGetCurrentKeyState = GetKeyState(vbKeyShift) < 0
Case vbKeyControl
jbGetCurrentKeyState = GetKeyState(vbKeyControl) < 0
End Select
End Function