Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is it possible to check wether the user of a Worksheet has CAPS LOCK set to
on or off |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to lock the Ctrl key? (as locking the Shift key w/Caps Lock) | Excel Discussion (Misc queries) | |||
Reverse Caps Lock | Excel Discussion (Misc queries) | |||
Force Caps Lock | Excel Programming | |||
Caps Lock | Excel Programming | |||
Caps lock | Excel Programming |