Hi ElGringo56
Where have you placed this Code?
- Should be in a STD Module
How to want to initiate the code?
- Via commandbutton or upon opening or
some other event.
This is a discussion on Keyboard functions within the Excel Questions forums, part of the Question Forums category; Option Explicit Private Const VK_CAPITAL = &H14 Private Type KeyboardBytes kbByte(0 To 255) As Byte End Type Private kbArray As ...
Option Explicit
Private Const VK_CAPITAL = &H14
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private kbArray As KeyboardBytes
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Long
Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Sub Caps_On()
GetKeyboardState kbArray
kbArray.kbByte(VK_CAPITAL) = 1
SetKeyboardState kbArray
MsgBox "Caps Lock is On"
End Sub
Sub Caps_Off()
GetKeyboardState kbArray
kbArray.kbByte(VK_CAPITAL) = 0
SetKeyboardState kbArray
MsgBox "Caps Lock is Off"
End Sub
I am trying to turn on or off Keyboard lock under macro control. This morning Ivan gave me this. I know so little, I cant seem to figure out how to use it. Can anyone help?
Sub Toggle_OnOff()
GetKeyboardState kbArray
kbArray.kbByte(VK_CAPITAL) = Not (kbArray.kbByte(VK_CAPITAL))
SetKeyboardState kbArray
MsgBox "Caps Lock is On:= " & Not (kbArray.kbByte(VK_CAPITAL) = 0)
End Sub
I dont know what an STD Module is???
I want to initiate it as I move down thru code, or maybe as I open a sheet, hmm, may be better if I did it when I opened the sheets I want caps on. Makes sence to me.
To get this to work when you open the workbook then.....On 2002-05-11 14:11, elgringo56 wrote:
I dont know what an STD Module is???
I want to initiate it as I move down thru code, or maybe as I open a sheet, hmm, may be better if I did it when I opened the sheets I want caps on. Makes sence to me.
From your Worksheet
1. Press Alt-F11 to display the Visual Basic editor.
2. In the Project Explorer window, find an entry for the Thisworkbook object. If you don't see the Project Explorer window, press Ctrl-R.
3. Double-click on thisworkbook entry in the Project Explorer window.
4. Paste this code here
Private Sub Workbook_Open()
Caps_On
End Sub
Is there a reason you want this on ?
If for input reasons then there are other
Options...ie allow users to input THEN convert.....
Bookmarks