Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Check for CAPS LOCK = ON

Is it possible to check wether the user of a Worksheet has CAPS LOCK set to
on or off
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Check for CAPS LOCK = ON

Got it!!!
in Module:

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type

' API declarations:
Private Declare Function GetVersionEx Lib "Kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long

Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwflags As Long, ByVal dwExtraInfo As Long)

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

' Constant declarations:
Const VK_CAPITAL = &H14

Function IsCapsLockOn() As Boolean
Dim o As OSVERSIONINFO

o.dwOSVersionInfoSize = Len(o)
GetVersionEx o
Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
IsCapsLockOn = keys(VK_CAPITAL)
End Function
'******END******


"akyhne" skrev:

Is it possible to check wether the user of a Worksheet has CAPS LOCK set to
on or off

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Check for CAPS LOCK = ON

I think you only need this much of what you posted:



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

' Constant declarations:
Const VK_CAPITAL = &H14

Function IsCapsLockOn() As Boolean

Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
IsCapsLockOn = keys(VK_CAPITAL)
End Function

--
Regards,
Tom Ogilvy


"akyhne" wrote in message
...
Got it!!!
in Module:

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type

' API declarations:
Private Declare Function GetVersionEx Lib "Kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long

Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwflags As Long, ByVal dwExtraInfo As Long)

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

' Constant declarations:
Const VK_CAPITAL = &H14

Function IsCapsLockOn() As Boolean
Dim o As OSVERSIONINFO

o.dwOSVersionInfoSize = Len(o)
GetVersionEx o
Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
IsCapsLockOn = keys(VK_CAPITAL)
End Function
'******END******


"akyhne" skrev:

Is it possible to check wether the user of a Worksheet has CAPS LOCK set

to
on or off



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Check for CAPS LOCK = ON

If you mean run the check each time the user starts typing, I don't believe
there is any built in method or event that would support that. You might be
able to craft something using the Windows API, but that isn't something I
can advise you on.

--
Regards,
Tom Ogilvy



"akyhne" wrote in message
...
I run this code on Worksheet.change.
That includes when VBA runs some macros.
How can I tell the Worksheet only to check by userkeystrokes

My code:

If IsCapsLockOn = False Then
MsgBox "Du skal skrive med store bogstaver." & vbln _
& "Slå [Caps Lock] til"
End If




"akyhne" skrev:

Works great!
thanks :-))

"Tom Ogilvy" skrev:

I think you only need this much of what you posted:



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

' Constant declarations:
Const VK_CAPITAL = &H14

Function IsCapsLockOn() As Boolean

Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
IsCapsLockOn = keys(VK_CAPITAL)
End Function

--
Regards,
Tom Ogilvy


"akyhne" wrote in message
...
Got it!!!
in Module:

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS

usage
End Type

' API declarations:
Private Declare Function GetVersionEx Lib "Kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long

Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwflags As Long, ByVal dwExtraInfo As Long)

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

' Constant declarations:
Const VK_CAPITAL = &H14

Function IsCapsLockOn() As Boolean
Dim o As OSVERSIONINFO

o.dwOSVersionInfoSize = Len(o)
GetVersionEx o
Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
IsCapsLockOn = keys(VK_CAPITAL)
End Function
'******END******


"akyhne" skrev:

Is it possible to check wether the user of a Worksheet has CAPS

LOCK set
to
on or off





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Check for CAPS LOCK = ON

Private Sub Worksheet_Change(ByVal Target As Range)

If IsCapsLockOn = False Then
MsgBox "Caps Lock should be on" & vbln _
& "Hit the [Caps Lock]"
End If
End Sub

In Module...
Private Declare Function GetKeyboardState Lib "user32" _
(pbKeyState As Byte) As Long

' Constant declarations:
Const VK_CAPITAL = &H14

Function IsCapsLockOn() As Boolean
Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
IsCapsLockOn = keys(VK_CAPITAL)
End Function



"Tom Ogilvy" skrev:

If you mean run the check each time the user starts typing, I don't believe
there is any built in method or event that would support that. You might be
able to craft something using the Windows API, but that isn't something I
can advise you on.

--
Regards,
Tom Ogilvy



"akyhne" wrote in message
...
I run this code on Worksheet.change.
That includes when VBA runs some macros.
How can I tell the Worksheet only to check by userkeystrokes

My code:

If IsCapsLockOn = False Then
MsgBox "Du skal skrive med store bogstaver." & vbln _
& "Slå [Caps Lock] til"
End If




"akyhne" skrev:

Works great!
thanks :-))

"Tom Ogilvy" skrev:

I think you only need this much of what you posted:



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

' Constant declarations:
Const VK_CAPITAL = &H14

Function IsCapsLockOn() As Boolean

Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
IsCapsLockOn = keys(VK_CAPITAL)
End Function

--
Regards,
Tom Ogilvy


"akyhne" wrote in message
...
Got it!!!
in Module:

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS

usage
End Type

' API declarations:
Private Declare Function GetVersionEx Lib "Kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long

Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwflags As Long, ByVal dwExtraInfo As Long)

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

' Constant declarations:
Const VK_CAPITAL = &H14

Function IsCapsLockOn() As Boolean
Dim o As OSVERSIONINFO

o.dwOSVersionInfoSize = Len(o)
GetVersionEx o
Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
IsCapsLockOn = keys(VK_CAPITAL)
End Function
'******END******


"akyhne" skrev:

Is it possible to check wether the user of a Worksheet has CAPS

LOCK set
to
on or off






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
How to lock the Ctrl key? (as locking the Shift key w/Caps Lock) Rick-cel Excel Discussion (Misc queries) 2 August 5th 09 06:45 PM
Reverse Caps Lock Amy Excel Discussion (Misc queries) 1 December 1st 05 04:18 AM
Force Caps Lock John[_78_] Excel Programming 21 June 1st 04 12:18 PM
Caps Lock Franco Turrinelli Excel Programming 0 February 25th 04 03:39 PM
Caps lock Paula Osheroff Excel Programming 2 October 13th 03 10:41 PM


All times are GMT +1. The time now is 12:01 AM.

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"