Canceling A Double Click Event

RobExcel

Board Regular
Joined
Jan 6, 2010
Messages
69
I'm using Excel 2007 on Win7.

I'd like to run some code if the user double clicks in certain cells. However, I don't want the double click to make Excel go into Edit mode. (It's annoying and interferes with the code that runs.)

Yesterday, I was able to do this by adding the line "Cancel = True" to my VBA.

Today, Excel doesn't seem to recognize the Cancel command. I've replicated this by opening a new workbook and adding the following code to Sheet1:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub

This does not prevent Excel from going into edit mode. Does anyone have a solution? Can others replicate the issue?

I assume that some setting/option has changed in my copy of Excel or that Microsoft released a patch, I just have no idea what it could be.

Thanks
Rob
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try adding to "Double _Click "Event.
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub
 
Upvote 0
Sorry, that was a type-o in the post, not what I was actually doing.

I can re-create the issue by putting this code in:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub
 
Upvote 0
While I don't understand it, I've now found that if I uninstall a particular commercial add-in, then reboot, and open the document again, the problem goes away.
 
Upvote 0
With the add-in installed, in the immediete window, type ?Application.EnableEvents and press the enter key. See if it returns False.
 
Upvote 0
No, events are enabled. I did find a class event that fires before a double click. The code is scrambled, so I can't read much of it, but I can tell that cancel is not set to true or false. I'm guessing that somehow Excel is remembering the custom class double click event's cancel and not my workbook specific one.

Oddly, I see that they also have a before right click event; however, I can get that one to work just fine.

I've worked around this by forcing an uninstall of the add-in.
 
Upvote 0

Forum statistics

Threads
1,224,591
Messages
6,179,768
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top