Lock the Keyboard

B

babs00

I've two questions :

- is it possible in excel to lock the keyboard i.e. user cannot press
any key or pressing a key does not have any effect.

- Secondly, if possible, can we lock the keyboard for a given range
only ? also, can we pass a message when user presses any key ?

Please don't quote Tools->Protection, I know about that option but
something else.
 
J

Jim Cone

You would have to use Excel programming code - VBA
or possibly a Windows API function.

Jim Cone
San Francisco, USA
 
J

Jim Cone

Take a look at the "Interactive" property of the
Application object. It blocks most use of the keyboard.

Also the following code could be experimented with...
'---------------------------------------------------------------
Laurent Longre ([email protected]) 10/12/2000
public.excel.programming
Re: Disabling All Key Combinations
Dim K
Dim Key
Dim Key2
Dim I As Integer
On Error Resume Next
K = Array("{BS}", "{BREAK}", "{CAPSLOCK}", "{CLEAR}", "{DEL}", _
"{DOWN}", "{END}", "{ENTER}", "~", "{ESC}", "{HELP}", "{HOME}", _
"{INSERT}", "{LEFT}", "{NUMLOCK}", "{PGDN}", "{PGUP}", _
"{RETURN}", "{RIGHT}", "{SCROLLLOCK}", "{TAB}", "{UP}")
For Each Key In Array("", "+", "^", "%", "+^", "+%", "^%", "+^%")
For Each Key2 In K
Application.OnKey Key & Key2, ""
Next Key2
For I = 1 To 15
Application.OnKey Key & "{F" & I & "}", ""
Next I
For I = 0 To 255
Application.OnKey Key & Chr$(I), ""
Next I
Next Key
-------------------------------
'(To enable "Normal" keys) jbc
-------------------------------
Dim Key, I As Integer
On Error Resume Next
For Each Key In Array("^", "%", "+^", "+%", "^%", "+^%")
For I = 32 To 255
Application.OnKey Key & Chr$(I)', ""
Next I
Next Key
'------------------------------------

I've never done much with this concept as I feel
it could turn very ugly on you.
User training is an alternative.

Jim Cone
San Francisco, USA
 
J

Jim Cone

Another approach could be...

In a regular module add code like this...
'----------------------
Sub InformUser()
Dim FirstAssumption
Dim SecondAssumption

'code here determines variable values

If FirstAssumption = SecondAssumption Then
MsgBox "Please do not make changes to the worksheet. " & vbCr & _
"Contact your supervisor if you have questions. ", _
vbCritical, " Don't do that"
Application.Undo
End If
End Sub
'----------------------
In the code module for the sheet add code like this...
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
'Call sub
InformUser
Application.EnableEvents = True
End Sub
'--------------------

Jim Cone
San Francisco, USA
 
B

babs00

Jim,

you're the man !! that's exactly what I was looking for - both
examples. I'd give them a try shortly and let you know how it worked.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

keyboard 1
scroll lock in Excel only 3
Minus Key Results in EXT Message in Status Bar 8
Lock Keyboard input 1
Miscrosoft Keyboard "F Lock" 5
Windows 7 Shift Lock 2
System Standby from Keyboard 3
Excel F2 & MS Media Keyboard 3

Top