Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA method to detect state of CAPSLOCK key?

Declare Function GetKeyboardState Lib "user32" _
(pbKeyState As Byte) As Long




Function CapsLock() As Boolean

Dim Res As Long
Dim KBState(0 To 255) As Byte

Res = GetKeyboardState(KBState(0))
CapsLock = KBState(&H14) And 1


End Function

Usage:

Sub ShowCapsLockState()
msgbox "Caps Lock on? " & capslock
End Sub

--
Regards,
Tom Ogilvy

"Jquads" wrote in message
...
I'm not looking for code to turn CAPSLOCK on or off; I simply want to

detect
the state of the CAPSLOCK key.

I'm running Excel10 and 11.

TIA for any suggestions.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
replace state names with state code abbreviations se7098 Excel Worksheet Functions 3 July 25th 09 06:41 PM
Detect open-state of xls from outside Excel Waterloo Excel Discussion (Misc queries) 2 May 6th 09 10:01 AM
toggle capslock when opening workbook Otto Excel Discussion (Misc queries) 1 August 6th 08 10:37 AM
How can I show state-by-state data (as silos) on a map of NA Rob Charts and Charting in Excel 0 November 5th 07 03:41 PM
Converting State Names to State Abbreviations aznate Excel Discussion (Misc queries) 1 October 20th 06 06:52 AM


All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"