Disable all shortcuts

E

ego

hello

I'm working with XLX with Panther and i would like with VBA disable
all the shortcuts but after my work i would like enabe the shortcuts.

Thanks Ego
 
J

JE McGimpsey

hello

I'm working with XLX with Panther and i would like with VBA disable
all the shortcuts but after my work i would like enabe the shortcuts.


You could disable individual keyboard shortcuts with

Application.OnKey "*p",""

to reset them:

Application.OnKey "*p"


If you have a lot that you wish to disable, you might consider something
like:

Public Sub DisableKeys()
Dim vKSArray As Variant
Dim i As Long
vKSArray = Array("*c", "*v", "*s", "*p")
For i = 0 To UBound(vKSArray)
Application.OnKey vKSArray(i), ""
Next i
End Sub

Public Sub EnableKeys()
Dim vKSArray As Variant
Dim i As Long
vKSArray = Array("*c", "*v", "*s", "*p")
For i = 0 To UBound(vKSArray)
Application.OnKey vKSArray(i)
Next i
End Sub

Now I've got 2 VERY STRONG recommendations (please don't be offended if
you've already thought about them - too many XL coders haven't):

1) This is a technique that would p*ss me off royally, especially if you
disable keyboard shortcuts that I like to use. Often there's another way
to accomplish what you're trying to do (which isn't clear from your
post). So I recommend you think about whether your users will be happy
with your hijacking their computer.

2) It's not uncommon to have more than just your workbook open. If I was
working on a model, opened your workbook, switched back to my model and
found I couldn't use my keyboard shortcuts, that would be the last time
I'd ever use your workbook! One way to be a good XL citizen is to use
the Workbook_Activate and Workbook_Deactivate events to disable your
customizations when switching to another workbook. For instance, you
could put this in your ThisWorkbook code module:

Private Sub Workbook_Activate()
DisableKeys
End Sub

Private Sub Workbook_Deactivate()
EnableKeys
End Sub
 
E

ego

JE McGimpsey said:
Now I've got 2 VERY STRONG recommendations (please don't be offended if
you've already thought about them - too many XL coders haven't):
......
2) It's not uncommon to have more than just your workbook open. If I was
working on a model, opened your workbook, switched back to my model and
found I couldn't use my keyboard shortcuts, that would be the last time
I'd ever use your workbook! One way to be a good XL citizen is to use
the Workbook_Activate and Workbook_Deactivate events to disable your
customizations when switching to another workbook. For instance, you
could put this in your ThisWorkbook code module:

Private Sub Workbook_Activate()
DisableKeys
End Sub

Private Sub Workbook_Deactivate()
EnableKeys
End Sub

Thanks for your answer and sorry for my poor english

I'v a problem with the macros disablekeys and enablekeys . When i stop
my macro and return to another workbook, Command c don't work the
first time . I need to pass by the menu and after the shortcut is
enable.

I made a little vba application for friends an teachers ( average of
the students) . But i need to protect formulas, format etc..... (Excel
is not very easy for them...)

My problem is to protect the format against command c and command v
but i need in my menu cut and paste for the transfert of notes.
Perhaps a better solution exist than disable the shortkeys

Thanks
 
J

JE McGimpsey

I'v a problem with the macros disablekeys and enablekeys . When i stop
my macro and return to another workbook, Command c don't work the
first time . I need to pass by the menu and after the shortcut is
enable.

I made a little vba application for friends an teachers ( average of
the students) . But i need to protect formulas, format etc..... (Excel
is not very easy for them...)

My problem is to protect the format against command c and command v
but i need in my menu cut and paste for the transfert of notes.
Perhaps a better solution exist than disable the shortkeys

There is a better way. Select the cells you want your users to have
access to and choose Format/Cells/Protection. Uncheck the locked
checkbox, then click OK. Then choose Tools/Protection/Protect
Worksheet... Give it a password if you wish (but see

http://www.mcgimpsey.com/excel/removepwords.html

for why passwords really don't provide any security).

Now your users will only be able to change the sells you unlocked.

I'm not sure why you're having to take extra steps to reenable CMD-c in
another workbook - for me it restores the function as soon as the switch
is made.
 
E

ego

JE McGimpsey said:
There is a better way. Select the cells you want your users to have
access to and choose Format/Cells/Protection. Uncheck the locked
checkbox, then click OK. Then choose Tools/Protection/Protect
Worksheet... Give it a password if you wish (but see

http://www.mcgimpsey.com/excel/removepwords.html

for why passwords really don't provide any security).

Now your users will only be able to change the sells you unlocked.

I'm not sure why you're having to take extra steps to reenable CMD-c in
another workbook - for me it restores the function as soon as the switch
is made.

i know that : no problem for protecting formulas but for the format !

How the users put a number in a cell witout change the format ? that's my problem

Thanks for your answer
 

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

Top