Function AfficheImage(NomImage As String, Rep As String)
Dim VPath As String
Application.Volatile
' Définir le chemin du répertoire
VPath = ThisWorkbook.Path & "\" & Rep & "\"
Rep = VPath
'
Set adr = Application.Caller
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 = "Inconnu"
Else
Set MyShell = CreateObject("Shell.Application")
Set MyFolder = MyShell.Namespace(Rep)
Set MyFile = MyFolder.Items.Item(NomImage)
Taille = MyFolder.GetDetailsOf(MyFile, 26)
H = Val(Split(Taille, "x")(1))
L = Val(Split(Taille, "x")(0))
Ech = adr.Height / H
lgcel = adr.Width
H = H * Ech
L = L * Ech
Set s = adr.Worksheet.Shapes.AddPicture(Rep & NomImage, True, True, adr.Left + adr.Width / 2 - L / 2 + 1, adr.Top + 1, L - 2, H - 2)
s.Name = NomImage & "_" & adr.Address
AfficheImage = "ok"
End If
End If
End Function