1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| Sub CopierImageEtEnregistrerEnJpg()
Dim NomFich
Dim FL1 As Worksheet
NomFich = "D:\xls\Image.jpg" 'Nom de la "future" image
Set FL1 = Worksheets("Feuil1")
FL1.Select
'Range("A1").Select
FL1.Shapes(FL1.Shapes.Count).Select 'sélection de l'image
Selection.Copy 'ou .cut
For i = 1 To 50000 'laisse au système le temps de copier l'image
DoEvents
Next
Set Graphe = Charts.Add 'insertion d'un graphe vide
Graphe.ChartType = xlLineMarkers 'ou autre...
Graphe.SetSourceData Source:=Sheets("Feuil1").Range("A1")
Graphe.Location Where:=xlLocationAsObject, Name:="Feuil1"
'La difficulté sera peut-être dans le redimensionnement du graphe
FL1.ChartObjects(FL1.ChartObjects.Count).Height = 900 'largeur du graphe
DoEvents
FL1.ChartObjects(FL1.ChartObjects.Count).Select 'sélection du graphe
ActiveChart.ChartArea.Select '
ActiveChart.Paste 'collage de l'image dans le graphe
DoEvents
DoEvents
Range("A1").Select
FL1.Shapes(FL1.Shapes.Count).Select
ActiveChart.Export NomFich, "JPG" 'Enregistrement de l'image
DoEvents
MsgBox "fini !"
FL1.ChartObjects(FL1.ChartObjects.Count).Select
Selection.Delete 'suppression du graphe avec son image
'CONTRÔLE : L'image existe-t-elle bien ?
FL1.Pictures.Insert("D:\xls\Image.jpg").Select 'insertion de l'image
Set FL1 = Nothing
End Sub |
Partager