#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Key event

How can I get a key press [down | up] event in Excel? Or,
how do I know if the delete key was pressed?

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Key event

Hi Greg,
Not available in Excel, why do you want it, what do you want to
check. There may be some alternatives are available.

There are some API material on Stephen Bullen's site
http://www.bmsltd.ie/Excel/Default.htm
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Greg" wrotel...
How can I get a key press [down | up] event in Excel? Or,
how do I know if the delete key was pressed?

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Key event

Hi Greg,
Not available in Excel, why do you want it, what do you want to
check. There may be some alternatives are available.

There are some API material on Stephen Bullen's site
http://www.bmsltd.ie/Excel/Default.htm
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Greg" wrotel...
How can I get a key press [down | up] event in Excel? Or,
how do I know if the delete key was pressed?

Thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Key event

Greg,

There is really no good way to do this. Perhaps if you describe
why you need to trap the Delete key, some one could come up with
a suitable workaround (e.g., the Change event procedure).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Greg" wrote in message
...
How can I get a key press [down | up] event in Excel? Or,
how do I know if the delete key was pressed?

Thanks!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Key event

I want to let the user delete selected text/content in
selected cells. However, I want the user to be unable to
delete rows at a time... I hope that makes sense... I
don't want the user to be able to select a row(s) and hit
delete...

Thanks!

-----Original Message-----
Greg,

There is really no good way to do this. Perhaps if you

describe
why you need to trap the Delete key, some one could come

up with
a suitable workaround (e.g., the Change event procedure).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Greg" wrote in

message
...
How can I get a key press [down | up] event in Excel?

Or,
how do I know if the delete key was pressed?

Thanks!



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Key event

Greg,

Have you taken a look at using the sheet protection command from the
Menubar. I'm not sure what version of Excel you have. The newer versions
allow a more granular control of protection including deletion of rows and
columns.

Alternatively, below is some code that uses Application.OnKey to trap the
Delete key. Test and see if it does what you want. You will need to call the
Initialize_DeleteTrap routine in a Workbook_Open event or something similar.

Troy

Sub Initialize_DeleteTrap()
Application.OnKey "{DEL}", "subDeletePressed"
End Sub

Sub subDeletePressed()
Dim rng As Range

If TypeName(Selection) = "Range" Then
Set rng = Selection
If rng.Address = rng.EntireRow.Address Then
MsgBox "Not allowed to delete entire row"
ElseIf rng.Address = rng.EntireColumn.Address Then
MsgBox "Not allowed to delete entire column"
Else
Application.OnKey "{DEL}"
SendKeys "{DEL}", True
Application.OnKey "{DEL}", "subDeletePressed"
End If
Else
Application.OnKey "{DEL}"
SendKeys "{DEL}", True
Application.OnKey "{DEL}", "subDeletePressed"
End If

Set rng = Nothing
End Sub

"Greg" wrote in message
...
I want to let the user delete selected text/content in
selected cells. However, I want the user to be unable to
delete rows at a time... I hope that makes sense... I
don't want the user to be able to select a row(s) and hit
delete...

Thanks!

-----Original Message-----
Greg,

There is really no good way to do this. Perhaps if you

describe
why you need to trap the Delete key, some one could come

up with
a suitable workaround (e.g., the Change event procedure).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Greg" wrote in

message
...
How can I get a key press [down | up] event in Excel?

Or,
how do I know if the delete key was pressed?

Thanks!



.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Key event

Why not unlock the cells you will allow the user to alter, then protect the
worksheet.

--
Regards,
Tom Ogilvy

"Greg" wrote in message
...
I want to let the user delete selected text/content in
selected cells. However, I want the user to be unable to
delete rows at a time... I hope that makes sense... I
don't want the user to be able to select a row(s) and hit
delete...

Thanks!

-----Original Message-----
Greg,

There is really no good way to do this. Perhaps if you

describe
why you need to trap the Delete key, some one could come

up with
a suitable workaround (e.g., the Change event procedure).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Greg" wrote in

message
...
How can I get a key press [down | up] event in Excel?

Or,
how do I know if the delete key was pressed?

Thanks!



.



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
Event Procedures: Event on Worksheet to fire Event on another Worksheet Kathryn Excel Programming 2 April 7th 04 07:35 PM
vba event Daniel P Excel Programming 4 February 20th 04 03:29 PM
Do Event John Gittins Excel Programming 1 October 22nd 03 04:58 PM
change event/after update event?? scrabtree23[_2_] Excel Programming 1 October 20th 03 07:09 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 05:38 PM.

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

About Us

"It's about Microsoft Excel"