+ Reply to Thread
Results 1 to 3 of 3

How can Excel vba detect if Caps Lock or Num Lock is on?

  1. #1
    abc
    Guest

    How can Excel vba detect if Caps Lock or Num Lock is on?

    Dear all,

    Can anyone help me?

    Thanks



  2. #2
    Robin Hammond
    Guest

    Re: How can Excel vba detect if Caps Lock or Num Lock is on?

    Here's one way. I'm sure there are others.

    'put these declarations at the top of the module
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long)
    As Integer
    Private Const kCapital = 20
    Private Const kNumlock = 144

    Public Function CapsLock() As Boolean
    CapsLock = KeyState(kCapital)
    End Function

    Public Function NumLock() As Boolean
    NumLock = KeyState(kNumlock)
    End Function

    Private Function KeyState(lKey As Long) As Boolean
    KeyState = CBool(GetKeyState(lKey))
    End Function

    Robin Hammond
    www.enhanceddatasystems.com

    "abc" <[email protected]> wrote in message
    news:%[email protected]...
    > Dear all,
    >
    > Can anyone help me?
    >
    > Thanks
    >
    >




  3. #3
    abc
    Guest

    Re: How can Excel vba detect if Caps Lock or Num Lock is on?

    It works! Thank you so much ^^

    "Robin Hammond" <[email protected]> ¦b¶l¥ó
    news:[email protected] ¤¤¼¶¼g...
    > Here's one way. I'm sure there are others.
    >
    > 'put these declarations at the top of the module
    > Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long)
    > As Integer
    > Private Const kCapital = 20
    > Private Const kNumlock = 144
    >
    > Public Function CapsLock() As Boolean
    > CapsLock = KeyState(kCapital)
    > End Function
    >
    > Public Function NumLock() As Boolean
    > NumLock = KeyState(kNumlock)
    > End Function
    >
    > Private Function KeyState(lKey As Long) As Boolean
    > KeyState = CBool(GetKeyState(lKey))
    > End Function
    >
    > Robin Hammond
    > www.enhanceddatasystems.com
    >
    > "abc" <[email protected]> wrote in message
    > news:%[email protected]...
    > > Dear all,
    > >
    > > Can anyone help me?
    > >
    > > Thanks
    > >
    > >

    >
    >




+ 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