-
Left and Right Mouse Click Event
-
Yes you can using
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox "Double-Clicked"
End Sub
OR
Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox "Right-Clicked"
End Sub
-
Hallo
Let's analyze:
Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox "Right-Clicked"
End Sub
In a paper without a password by running the code occur at least two possibilities.
Example: I make right click on a cell and activate the macro, but if I were on an image this command does not work.
You can disable the selection image forever without protect the sheet?
-
To disable the selection of image, you will have to protect the sheet. If you want users to be able to edit the cells, you can unlock the cells, and then protect the sheet.
-
Hallo
This is an example of code to enable I can not enter password
Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
Application.CommandBars.FindControl(ID:=130).Execute
end sub
I would like to draw a line on the sheet and images
-
You can protect the sheet through code and then allow to draw a line through code. To do this, protect the sheet(s) by
Code:
Sheet1.Protect UserInterfaceOnly:=True, Password:="xyz"
-
Meanwhile, thank you for the answers, but if I run RightClick on protected sheet over an image the event does not Run.
Here we are again as the first
-
Why do you want to right-click? You can use a normal click, and the assigned macro will run even if the sheet is protected. And if you want the shapes also to be unprotected, then use
Code:
Sheet1.Protect UserInterfaceOnly:=True, Password:="xyz", DrawingObjects:=False
-
Hallo
Still to solve the problems of selection wonder how the subject should be written the following code:
Code:
Sub Test()
ActiveSheet.Shapes("Picture 309").Select 'I select the object
ActiveSheet.Shapes("Picture 309").Deselect 'Here I would like to deselect the object
End Sub
Obviously, the code does not work ...
-
Code:
Sub Test()
ActiveSheet.Shapes("Picture 309").TopLeftCell.Select
End Sub