Private Sub NoFlacon_Change()
Dim i As Variant, s As Shape, fichier$
With Sheets("Feuil1")
i = Application.Match(Val(NoFlacon), .[A:A], 0)
If IsError(i) Then
Fournisseur = "": Nom = "": Lot = "": Avertissement = ""
Image1.Picture = LoadPicture("")
Else
Fournisseur = .Cells(i, 2)
Nom = .Cells(i, 3)
Lot = .Cells(i, 4)
Avertissement = .Cells(i, 5)
For Each s In Sheets("Picto").Shapes
If s.Name = Avertissement Then Exit For
Next
If s Is Nothing Then Image1.Picture = LoadPicture(""): Exit Sub
fichier = ThisWorkbook.Path & "\MonImage.gif"
'---création du fichier image gif---
s.CopyPicture xlScreen, xlBitmap
With s.Parent.ChartObjects.Add(0, 0, s.Width, s.Height).Chart
While .Shapes.Count = 0 'en attente du collage
DoEvents
.Paste
Wend
.Export fichier, "GIF"
.Parent.Delete 'supprime le graphique temporaire
End With
'---image de l'UserForm---
Image1.PictureSizeMode = fmPictureSizeModeClip 'fmPictureSizeModeStretch
Image1.Picture = LoadPicture(fichier)
Kill fichier 'suppression du fichier image
End If
End With
End Sub