Click to See Complete Forum and Search --> : problem with SENDKEYS capslock
tonyelyn
Jun 11th, 2005, 01:25 AM
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.
westconn1
Jun 11th, 2005, 02:47 AM
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
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)
'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 (http://www.mvps.org/access/api/api0046.htm) where i found the code
pete
tonyelyn
Jun 11th, 2005, 01:08 PM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.