I would love to know how to turn CAPSLOCK on and off using VBA.
Thanks!
I would love to know how to turn CAPSLOCK on and off using VBA.
Thanks!
I found a solution at http://www.excel-center.de/excel/handbuch.php
go to API no. 11 if you don't read German or don't have a web page translator.
Cheers!
Found an even easier way that works for all keys as long as you know their code. For example, CAPSLOCK is &H14.
Private Sub Workbook_Open()
SetKeyState &H14, True
End Sub
Declare Function GetKeyboardState Lib "user32" _
(pbKeyState As Byte) As Long
Declare Function SetKeyboardState Lib "user32" _
(lppbKeyState As Byte) As Long
Sub SetKeyState(intKey As Integer, bTurnOn As Boolean)
' Retrieve the keyboard state, set the particular
' key in which you're interested, and then set
' the entire keyboard state back the way it
' was, with the one key altered.
Dim abytBuffer(0 To 255) As Byte
GetKeyboardState abytBuffer(0)
abytBuffer(intKey) = CByte(Abs(bTurnOn))
SetKeyboardState abytBuffer(0)
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks