VBA method to detect state of CAPSLOCK key?
Declare Function GetKeyboardState Lib "user32" _
(pbKeyState As Byte) As Long
Function CapsLock() As Boolean
Dim Res As Long
Dim KBState(0 To 255) As Byte
Res = GetKeyboardState(KBState(0))
CapsLock = KBState(&H14) And 1
End Function
Usage:
Sub ShowCapsLockState()
msgbox "Caps Lock on? " & capslock
End Sub
--
Regards,
Tom Ogilvy
"Jquads" wrote in message
...
I'm not looking for code to turn CAPSLOCK on or off; I simply want to
detect
the state of the CAPSLOCK key.
I'm running Excel10 and 11.
TIA for any suggestions.
|