Sub POP_UP()
Dim P As Range, x$, fichier$
Set P = Sheets("Liste").[A1].CurrentRegion 'la feuille Liste est masquée
x = UserForm1.Caption
Select Case Val(Right(ActiveSheet.DrawingObjects(Application.Caller).Text, 1))
Case 1: Set P = P.Resize(8): UserForm1.Caption = x & " N° 1"
Case 2: Set P = P.Resize(16): UserForm1.Caption = x & " N° 2"
Case 3: UserForm1.Caption = x & " N° 3"
End Select
fichier = ThisWorkbook.Path & "\MonImage.gif"
'---création du fichier image gif---
P.CopyPicture xlScreen, xlBitmap
With P.Parent.ChartObjects.Add(0, 0, P.Width, P.Height).Chart
While .Shapes.Count = 0 'en attente du collage
DoEvents
.Paste
Wend
.Export fichier, "GIF"
.Parent.Delete 'supprime le graphique temporaire
End With
'---dimensionnement et remplissage de l'UserForm---
With UserForm1
.Width = P.Width + 24
.Height = P.Resize(6).Height + 30 'affiche 6 lignes
.ScrollBars = fmScrollBarsVertical 'barre de défilement
.ScrollHeight = P.Height
.ScrollWidth = P.Width
.PictureSizeMode = fmPictureSizeModeClip
.Picture = LoadPicture(fichier)
Kill fichier 'suppression du fichier image
.Show
End With
End Sub