Private Sub Worksheet_BeforeDoubleClick(ByVal c As Range, Cancel As Boolean)
Dim P As Range, chemin$, nom$, nomA$, url$, a, o As Object
If c.Address = "$B$1" Then
Cancel = True
For Each c In Me.UsedRange.Rows(1).Cells
If c Like "ajout*" Then Set P = Union(IIf(P Is Nothing, c, P), c)
Next
If Not P Is Nothing Then P.EntireColumn.Hidden = Not P(1).EntireColumn.Hidden
ElseIf c.Row > 1 And c.Column > 1 And c <> "" Then
Cancel = True
chemin = ActiveWorkbook.Path & "\Photos acteurs\"
nom = c(1, 3 - c.Column) 'nom en colonne B
nomA = chemin & nom & IIf(c.Column > 2, " " & c, "") 'nom + ajout
If Dir(chemin, vbDirectory) = "" Then MkDir chemin 'creation du sous-dossier
If Dir(nomA & ".png") & Dir(nomA & ".jpg") = "" Then
url = "https://www.google.fr/search?hl=fr&site=imghp&tbm=isch&q=" & Replace(nom, " ", "+")
a = Shell("C:\Program Files\Internet Explorer\iexplore.exe " & url, vbNormalFocus)
Else
Application.ScreenUpdating = False
On Error Resume Next
Set o = Me.Pictures.Insert(nomA & ".png") 'image temporaire, celle-ci
Set o = Me.Pictures.Insert(nomA & ".jpg") 'sinon celle-la
c.ClearComments
c.AddComment
c.Comment.Shape.Width = o.Width
c.Comment.Shape.Height = o.Height
c.Comment.Shape.Fill.UserPicture nomA & ".png" 'ceci
c.Comment.Shape.Fill.UserPicture nomA & ".jpg" 'sinon cela
o.Delete
End If
End If
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal c As Range, Cancel As Boolean)
If c.Row = 1 Or c.Column = 1 Or c(1) = "" Then Exit Sub
If MsgBox("S'ils existent, le commentaire et le fichier de l'image seront supprimés." _
& vbLf & "Voulez vous continuer ?", 4, "Cellule " & c(1).Address(0, 0)) = 7 Then Exit Sub
Dim chemin$, nomA$
Cancel = True
chemin = ActiveWorkbook.Path & "\Photos acteurs\"
nomA = chemin & c(1, 3 - c.Column) & IIf(c.Column > 2, " " & c(1), "")
c(1).ClearComments
On Error Resume Next
Kill nomA & ".png"
Kill nomA & ".jpg"
End Sub