Re: VBA method to detect state of CAPSLOCK key?
From: Tom Ogilvy (twogilvy_at_msn.com)
Date: 09/17/04
- Next message: Tom Ogilvy: "Re: Code works with Excel 2000 but not with Excel 2002"
- Previous message: Peter Ostermann: "Re: Wrong data format?"
- In reply to: Jquads: "VBA method to detect state of CAPSLOCK key?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 17 Sep 2004 16:17:19 -0400
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" <Jquads@discussions.microsoft.com> wrote in message news:C3946CC9-BA73-449C-B9E3-D80514F2A22E@microsoft.com... > 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.
- Next message: Tom Ogilvy: "Re: Code works with Excel 2000 but not with Excel 2002"
- Previous message: Peter Ostermann: "Re: Wrong data format?"
- In reply to: Jquads: "VBA method to detect state of CAPSLOCK key?"
- Messages sorted by: [ date ] [ thread ]