J'ai créée dans un userform un spreadsheet (avec owc11) et je souhaiterais que quand je clique dans ce spreadsheet que mon clic droit ou mon clic gauche soit détecté.
J'ai le code suivant
Code:
Private Declare Function GetAsyncKeyState Lib "User32" (ByVal vKey As Long) As Long 'fonction API qui sert à gerer les clics de la souris
Private Sub UserForm1_Spreadsheet1_BeforeRightClick(ByVal target As Range, cancel As Boolean)
cancel = True 'clic droit par défaut
MsgBox ("test")
If UserForm1.Spreadsheet1.Sheets("Feuil1").target.Interior.ColorIndex = 1 Then
MsgBox ("Clique sur une case Bleu")
End If
End Sub
Private Sub UserForm1_Spreadsheet1_SlectionChange(ByVal target As Range)
If GetAsyncKeyState(2&) Then 'Si il y a un clic droit on n'exécute pas ce clic gauche
Exit Sub
End If
If target.Interior.ColorIndex = 1 Then
MsgBox ("Clique sur une case Bleu")
End If
End Sub
Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then MsgBox "Le Bouton Droit n'a aucun effet!"
End Sub