Sub decoupe(Optional chem As String = "")
Dim w As Single, h As Single, shap As Shape
With ActiveSheet
Set shap = .Shapes.AddPicture(tbchemin, False, True, 0, 0, -1, -1) 'insère l'image a sa taille d'origine
DoEvents
With shap
w = .Width: h = .Height
.PictureFormat.CropLeft = w * (Val(crleft.Value) / 100)
.PictureFormat.CropRight = w * (Val(crright.Value) / 100)
.PictureFormat.CropTop = h * (Val(crtop.Value) / 100)
.PictureFormat.CropBottom = h * (Val(crbot.Value) / 100)
If echorigin = False Then
.LockAspectRatio = True
.Width = .Width / (w / Image1.Width)
DoEvents
End If
End With
If chem = "" Then
appercu
Else
shap.CopyPicture
DoEvents
With .ChartObjects.Add(shap.Left, shap.Top, shap.Width, shap.Height)
'il faut ajouter le Select avant de faire le Paste
.Select
.Chart.Paste
.Chart.Export Filename:=chem
.Delete
shap.Delete
End With
End If
End With
End Sub