Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can Excel vba detect if Caps Lock or Num Lock is on?

120 views
Skip to first unread message

abc

unread,
Dec 1, 2005, 11:10:06 PM12/1/05
to
Dear all,

Can anyone help me?

Thanks


Robin Hammond

unread,
Dec 2, 2005, 12:27:43 AM12/2/05
to
Here's one way. I'm sure there are others.

'put these declarations at the top of the module
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long)
As Integer
Private Const kCapital = 20
Private Const kNumlock = 144

Public Function CapsLock() As Boolean
CapsLock = KeyState(kCapital)
End Function

Public Function NumLock() As Boolean
NumLock = KeyState(kNumlock)
End Function

Private Function KeyState(lKey As Long) As Boolean
KeyState = CBool(GetKeyState(lKey))
End Function

Robin Hammond
www.enhanceddatasystems.com

"abc" <a...@abc.com> wrote in message
news:%23NroIZv...@tk2msftngp13.phx.gbl...

abc

unread,
Dec 2, 2005, 1:14:46 AM12/2/05
to
It works! Thank you so much ^^

"Robin Hammond" <rjNOr...@PLEASEnetvigator.com> 在郵件
news:uU54BEw9...@TK2MSFTNGP09.phx.gbl 中撰寫...

0 new messages