#1   Report Post  
 
Posts: n/a
Default Lock the Keyboard

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.

  #2   Report Post  
Jim Cone
 
Posts: n/a
Default

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

Jim Cone
San Francisco, USA


wrote in message
ups.com...
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.

  #3   Report Post  
 
Posts: n/a
Default

I'm ok to use either of these. Could you please suggest some example ?

  #4   Report Post  
Jim Cone
 
Posts: n/a
Default

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 ) 10/12/2000
public.excel.programming
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


wrote in message
oups.com...
I'm ok to use either of these. Could you please suggest some example ?

  #5   Report Post  
Jim Cone
 
Posts: n/a
Default

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



"Jim Cone" wrote in message
...
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 ) 10/12/2000
public.excel.programming
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



wrote in message
oups.com...
I'm ok to use either of these. Could you please suggest some example ?




  #6   Report Post  
 
Posts: n/a
Default

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.

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 worksheet formatting? TANDEX Excel Worksheet Functions 3 May 11th 05 10:22 PM
How to lock worksheet formatting? TANDEX Excel Worksheet Functions 1 May 6th 05 09:36 PM
keyboard shortcut Aditya Excel Worksheet Functions 1 February 21st 05 01:34 PM
Why is pointer and keyboard control is lost in certain Excel file. MarkB3 Excel Discussion (Misc queries) 0 January 4th 05 07:15 PM
scroll lock PCOR Excel Discussion (Misc queries) 6 December 5th 04 08:08 PM


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

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

About Us

"It's about Microsoft Excel"