Private Sub Worksheet_Change(ByVal Target As Range)
Dim fichier$, x#, y#, o As Object
fichier = ThisWorkbook.Path & "\ImagePlage.jpg"
'---création du fichier JPEG---
Application.ScreenUpdating = False
With [H8].CurrentRegion 'à adapter
x = .Width
y = .Height
.CopyPicture
End With
Set o = ChartObjects.Add(0, 0, x, y)
Do
o.Chart.Paste
DoEvents
Loop While TypeName(Selection) = "Range" 'en attente de création de la Shape
o.Chart.Export fichier, "JPG"
o.Delete
'---création du commentaire---
With [D8] 'à adapter
.ClearComments 'RAZ
.AddComment ""
.Comment.Shape.Fill.UserPicture fichier 'insère l'image
.Comment.Shape.Width = x
.Comment.Shape.Height = y
End With
Kill fichier 'supprime le fichier JPEG
End Sub