Gurileck


I have made use of the onkey function in vba to disable most keyboard shortcuts, however if the user is in the middle of entering text into a cell, he can press any of the disabled shortcuts and they will work. Is there any way to make them stay disabled



Re: Can I disable keys in Excel while a cell is selected?

MyLady


Hey,

Can you show an example code how you disable a key with the OnKey method

Best Regards

Cathrine






Re: Can I disable keys in Excel while a cell is selected?

Gurileck

Hi,

I used the format of

Application.OnKey "^c", ""

to disable ctrl+c, and did that for a long list of keys that I want disabled. the module it is in is called when the workbook is
loaded. Then when the workbook is closed, all the keys revert back to default

Application.OnKey "^c"

Everything works except that if you are in the middle of entering text in a cell, the keys will all do their original functions.





Re: Can I disable keys in Excel while a cell is selected?

MyLady

Hey,

The key sequence, SHIFT+CTRL+RIGHT ARROW, highlight the row from the active cell and to right (to first cell if a value is present).

'disable SHIFT+CTRL+RIGHT ARROW

Application.OnKey "+^{RIGHT}", ""

When disabled, try if the key sequence highlights the row (cells) ore not when you are in the middle of entering text in a cell.

I am using Excel 2003, and it works for me.

Cath





Re: Can I disable keys in Excel while a cell is selected?

Gurileck

well, that one seemed to work, but try disabling F3 for example (paste name). It disables it except for when in the middle of entering text and at that point the key works and it shouldn't.