Private Sub Workbook_Open()
Dim fichier$, P As Range
fichier = ThisWorkbook.Path & "\MonImage.gif"
Set P = Sheets("CDD").[A1].CurrentRegion
Application.ScreenUpdating = False
P.CopyPicture
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
With UserForm1
.Frame1.Picture = LoadPicture(fichier)
.Frame1.PictureAlignment = fmPictureAlignmentTopLeft
.Frame1.PictureSizeMode = fmPictureSizeModeClip
.Frame1.ScrollHeight = P.Height
.Frame1.Width = P.Width + 18
.Width = P.Width + 42
.Show 0 'non modal
End With
Kill fichier 'suppression du fichier image
Application.ScreenUpdating = True
End Sub