Saberexcel - o site das macros
Essas declarações API do Aplicativo Microsoft Excel VBA, ativa ou desativa as teclas NUMLOOK E E CAPSLOOK.
VBA Excel - Ativa NUMLOOK e CAPSLOOK API
VBA Excel - estas declaração e a macro ativa o NUM LOOK and CAPSLOCK API
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Dim kbArray As KeyboardBytes
Private Declare Function GetKeyState Lib _
"User32" (ByVal nVirtKey) As Long
Private Declare Function GetKeyboardState Lib _
"User32" (kbArray As KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib _
"User32" (kbArray As KeyboardBytes) As Long
Const VK_NUMLOCK = &H90
Sub CapsLockOn()
GetKeyboardState kbArray
kbArray.kbByte(VK_NUMLOCK) = 1
SetKeyboardState kbArray
End Sub
Sub CapsLockOff()
GetKeyboardState kbArray
kbArray.kbByte(VK_NUMLOCK) = 0
SetKeyboardState kbArray
End Sub
'..........................'
Declare Function GetKeyboardState Lib “user32″ _
(pbKeyState As Byte) As Long
Declare Function SetKeyboardState Lib “user32″ _
(lppbKeyState As Byte) As Long
Sub SetMyNumLock()
‘ NUMLOCK Ligado e CAPSLOCK desligado
Dim Res As Long
Dim KBState(0 To 255) As Byte
Res = GetKeyboardState(KBState(0))
KBState(&H90) = 1 ‘ num lock 1 = on, 0 = off
KBState(&H14) = 0 ‘ caps lock 1 = on, 0 = off
Res = SetKeyboardState(KBState(0))
End Sub
Aprenda tudo sobre o Aplicativo Microsoft Excel VBA com Saberexcel - o site das macros