B
Brian Stigler
I would like to toggle the Insert Key ON when a certain type of form is
diaplayed. I have been able to get the state of the Insert Key but can't
set the state via my class module. I get an error stating Can't Find DLL
entry point for GetKeyboardState in "user32"...
I'm using Office XP "Word 10" and have created the below class module and
program calls... I'm guessing I'm using an outdated library or something???
Any help would be greatly appreciated. NOTE: code was "lifted" from an
example in an EXCEL Programming book by John Walkenbach for toggling the
NUMLOCK key. I just replaced NUMLOCK with INSERTKEY. I want to use the
code in Word not EXCEL...
Thanks,
Brian
'*****My Calls*******
Private Sub Toggle_Insert_Key_ON()
Dim InsertKey As New InsertKeyClass
InsertKey.Value = True
End Sub
'
Private Sub Toggle_Insert_Key_OFF()
Dim InsertKey As New InsertKeyClass
InsertKey.Value = False
End Sub
'***CLASS MODULE - InsertKeyClass***
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private kbArray As KeyboardBytes
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long)
As Long
Private Declare Function GetKeyBoardState Lib "user32" (kbArray As
KeyboardBytes) As Long
Private Declare Function SetKeyBoardState Lib "user32" (kbArray As
KeyboardBytes) As Long
'
Property Get Value() As Boolean
Value = GetKeyState(vbKeyInsert) And 1 = 1 ' &H2D
End Property
'
Property Let Value(boolVal As Boolean)
GetKeyBoardState kbArray
kbArray.kbByte(vbKeyInsert) = Abs(boolVal)
SetKeyBoardState kbArray
End Property
diaplayed. I have been able to get the state of the Insert Key but can't
set the state via my class module. I get an error stating Can't Find DLL
entry point for GetKeyboardState in "user32"...
I'm using Office XP "Word 10" and have created the below class module and
program calls... I'm guessing I'm using an outdated library or something???
Any help would be greatly appreciated. NOTE: code was "lifted" from an
example in an EXCEL Programming book by John Walkenbach for toggling the
NUMLOCK key. I just replaced NUMLOCK with INSERTKEY. I want to use the
code in Word not EXCEL...
Thanks,
Brian
'*****My Calls*******
Private Sub Toggle_Insert_Key_ON()
Dim InsertKey As New InsertKeyClass
InsertKey.Value = True
End Sub
'
Private Sub Toggle_Insert_Key_OFF()
Dim InsertKey As New InsertKeyClass
InsertKey.Value = False
End Sub
'***CLASS MODULE - InsertKeyClass***
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private kbArray As KeyboardBytes
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long)
As Long
Private Declare Function GetKeyBoardState Lib "user32" (kbArray As
KeyboardBytes) As Long
Private Declare Function SetKeyBoardState Lib "user32" (kbArray As
KeyboardBytes) As Long
'
Property Get Value() As Boolean
Value = GetKeyState(vbKeyInsert) And 1 = 1 ' &H2D
End Property
'
Property Let Value(boolVal As Boolean)
GetKeyBoardState kbArray
kbArray.kbByte(vbKeyInsert) = Abs(boolVal)
SetKeyBoardState kbArray
End Property