Function AfficheImage(NomImage, Optional rep)
Application.Volatile
If IsMissing(rep) Then rep = ThisWorkbook.Path & "\Photo\"
Set adr = Application.Caller
Set adr2 = Range(adr.Address).MergeArea
temp = NomImage & "_" & adr.Address
Existe = False
For Each s In adr.Worksheet.Shapes
If s.Name = temp Then Existe = True
Next s
If Not Existe Then
For Each k In adr.Worksheet.Shapes
p = InStr(k.Name, "_")
If Mid(k.Name, p + 1) = adr.Address Then k.Delete
Next k
If Dir(rep & NomImage) = "" Then
AfficheImage = "Photo"
Else
Set myShell = CreateObject("Shell.Application")
If TypeName(rep) = "Range" Then
Set myFolder = myShell.Namespace(rep.Value)
Else
Set myFolder = myShell.Namespace(rep)
End If
Set myFile = myFolder.Items.Item(NomImage)
Taille = myFolder.GetDetailsOf(myFile, 26)
H = Val(Split(Taille, "x")(1))
L = Val(Split(Taille, "x")(0))
echH = adr2.Height / H
EchL = adr2.Width / L
If L * echH > adr2.Width Then ech = EchL Else ech = echH
H = H * ech
L = L * ech - 2
Set s = adr.Worksheet.Shapes.AddPicture(rep & NomImage, True, True, adr.Left, adr.Top, L, H)
s.Name = NomImage & "_" & adr.Address
AfficheImage = ""
End If
End If
End Function