Automatic caps lock

  • Thread starter Thread starter Birdy
  • Start date Start date
B

Birdy

Rather new here, couldn't find in an nntp search, or on the web side.
Q: How can I automatically turn on caps lock when I boot excel?
Remedial, I know, but you all are soooo much more advanced than I.
 
Here is a bit of code I was using before I learned about a UPPER() function.
Thats a bit violent :
'------------
Option Explicit

Private Declare Function SetKeyboardState Lib "user32" _
(lppbKeyState As Byte) As Long
Private Declare Function GetKeyboardState Lib "user32" _
(lppbKeyState As Byte) As Long

Private Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Integer

Private Sub SetKeyState(ByVal Key As Long, ByVal State As Boolean)
Dim Keys(0 To 255) As Byte
GetKeyboardState Keys(0)
Keys(Key) = Abs(CInt(State))
SetKeyboardState Keys(0)
End Sub

public Sub setCapsLock(ByVal Value As Boolean)
SetKeyState KeyCodeConstants.vbKeyCapital, Value
End Sub
'-------------

Now you can call
setCapsLock(true) in a autorun macro
and
setCapsLock(false) in a autclose

ONE PROBLEM : the keyboard indicators are not refreshed, but it's really in
caps

I Highly recommend using a Upper() function (if that's possible).

HTH
Christophe
 
Back
Top