Sub Affichephoto()
Dim c
répertoire = ThisWorkbook.Path
NomImage = Application.Caller
For Each c In Array(".jpg", ".png", ".gif", ".bmp")
If Dir(répertoire & "\" & NomImage & c) <> "" Then
taille = TaillePixelsImage(répertoire, NomImage & c)
larg = Split(taille)(2)
haut = Split(taille)(2)
rap = Val(Mid(haut, 2)) / Val(Mid(larg, 2))
UserForm1.Image1.Height = 700
UserForm1.Image1.Width = UserForm1.Image1.Height * rap
UserForm1.Height = UserForm1.Image1.Height + 20
UserForm1.Width = UserForm1.Image1.Width
UserForm1.Image1.Picture = LoadPicture(répertoire & "\" & NomImage & c)
UserForm1.Show
End If
Next
End Sub
Function TaillePixelsImage(repertoire, fichier)
Set myShell = CreateObject("Shell.Application")
Set myFolder = myShell.Namespace(repertoire)
Set myFile = myFolder.Items.Item(fichier)
TaillePixelsImage = myFolder.GetDetailsOf(myFile, 176) & " " & myFolder.GetDetailsOf(myFile, 178)
End Function