Trapping the mouse

  • Thread starter Thread starter Sam K
  • Start date Start date
S

Sam K

I would like to trap a key stroke before processing some code and then
activating the stroke after.
Can I do something similar to a mouse click?

Thanks in advance for any clue,
Sam K
 
Hi Sam K,

If talk about mouse click on worksheets, unfortunately there are only two
events for mouse: Double click and Right click. If you want to test them,
try this:

- Open your Workbook
- Right click sheet tab
- Click View Code command
- Insert the code below:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
MsgBox "You double click at " & Target.Address
Cancel = True 'This avoid default behavior
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As
Boolean)
MsgBox "You right click at " & Target.Address
Cancel = True 'This avoid default behavior
End Sub


- Press Alt+F11 to back Excel window
- Try double click and right click the sheet cells.


HTH
 
Back
Top