|
-
Jun 11th, 2005, 01:25 AM
#1
Thread Starter
New Member
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.
Last edited by tonyelyn; Jun 11th, 2005 at 01:12 PM.
Reason: Problem solved
-
Jun 11th, 2005, 02:47 AM
#2
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
Last edited by westconn1; Jun 11th, 2005 at 03:08 AM.
-
Jun 11th, 2005, 01:08 PM
#3
Thread Starter
New Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|