+ Reply to Thread
Results 1 to 4 of 4

How to Turn CAPS LOCK off / on?

  1. #1
    Forum Contributor
    Join Date
    03-24-2005
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    378

    How to Turn CAPS LOCK off / on?

    Is there a simple code to detect the current state of the Caps Lock?

    A coworker has a spreadsheet used by many people, she wants all entries to be capitilized.

    What I would like to do is detect the Caps Lock state with Private Sub Workbook_Open () and save that state (in a hidden sheet? Suggestion?) Then, ensure the Caps lock is on.

    When the workbook is closed, I want to use Private Sub Workbook_BeforeClose () to return the Caps Lock to the state it was prior to this workbook being opened.
    Thanks!
    Dennis

    I am using Windows 7 and Office 2007, all of my posts are based on this.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Call this macro from the Workbook_Open_Event

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good afternoon DCSwearingen

    This is not an easy thing to do. You need to use keyboard hooks, API's and Class modules to actually affect the CapsLock (or NumLock, or ScrollLock). There is a routine here which is fairly easy to implement that will detect the state of the CapsLock :
    http://vbnet.mvps.org/index.html?code/internet/ping.htm

    I do have a routine which I can't reproduce on here which will turn on or off CapsLock automatically. If anyone wants it, just PM me your e-mail address.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  4. #4
    Forum Contributor
    Join Date
    03-24-2005
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    378

    My Solution

    shLookup is the name property for a hidden sheet in the workbook.

    Modifying the suggestion by royUK, this code is in ThisWorkbook:

    I call this routine from the Workbook_Open event:
    Please Login or Register  to view this content.
    and I call this routine from the Workbook_BeforeClose event:
    Please Login or Register  to view this content.
    It isn't automatic, but it does remind the user when to change the Caps Lock...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1