Results 1 to 3 of 3

Thread: problem with SENDKEYS capslock

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    6

    Resolved 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

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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:
    1. Const KEYEVENTF_EXTENDEDKEY = &H1
    2. Const KEYEVENTF_KEYUP = &H2
    3.       Private Declare Sub keybd_event Lib "user32" _
    4.          (ByVal bVk As Byte, _
    5.           ByVal bScan As Byte, _
    6.           ByVal dwflags As Long, ByVal dwExtraInfo As Long)

    VB Code:
    1. 'Simulate Key Press
    2.             keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
    3.           'Simulate Key Release
    4.             keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY _
    5.                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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    6

    Resolved 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
  •  



Click Here to Expand Forum to Full Width