problem with SENDKEYS capslock
I'm having a few unprotected cells on a EXCELL worksheet. The user has to type in some text, but in capital letters. I hoped at the same moment of opening the file, a SENDKEYS capslock would help. I tried to type in
SENDKEYS "{CAPSLOCK}"
in my code and/or in the immidiate window of the visual basic editor. No warning messages, but nothing changed.
Can somebody help me or give me a better way to prevent the user to use small letters.
Re: problem with SENDKEYS capslock
try
SendKeys "{CAPSLOCK}"
SendKeys "abceded", True
this works in as much as the second string is sent in caps, but typing into the app is still as the keyboard state
VB Code:
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwflags As Long, ByVal dwExtraInfo As Long)
VB Code:
'Simulate Key Press
keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
'Simulate Key Release
keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY _
Or KEYEVENTF_KEYUP, 0
the above code will toggle the caps lock key in windows nt or xp
for more information like if you want to get the keyboard state first
see mvps site where i found the code
pete
Re: problem with SENDKEYS capslock
tHANK YOU FOR YOUR HELP.
I'm new in VBA and the first 2 codes did'nt make me smarter.
I found a solution in the further help you told me where I could find it.