Thread: vbKeyCapital
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default vbKeyCapital

Give this a wirl...

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

Sub Test()
MsgBox CapsLock
MsgBox NumLock
End Sub

--
HTH...

Jim Thomlinson


"jnf40" wrote:

I have a workbook that when opened a box pops up for the user to enter a
password. I would like to have a message box pop up if the CapsLock is on,
this way if they can enter the password correctly. As it is now if they type
in the password and they have the CapsLock on it will only give them viewing
rights. Is it possible to have Excel recognize when the CapsLock is on, if so
how would I put this into code?
Thanks in advance,
jnf40