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
| Sub TestCreationImage()
Dim Sh As Worksheet
Set Sh = Sheets("Feuil1")
CopiePlageDeCelluleEtExporterImage Sh, Sh.Range("A1:Y25"), "photo mer.jpg", "C:\Users\Jean-Paul. Masson\Pictures\", Sh.Range("E33")
Set Sh = Nothing
End Sub
Sub CopiePlageDeCelluleEtExporterImage(ByVal FeuilleImage As Worksheet, ByVal AireImage As Range, ByVal NomDeLImage As String, ByVal RepertoireImage As String, ByVal CelluleLien As Range)
Dim ShChObj As ChartObject
With FeuilleImage
AireImage.CopyPicture
Set ShChObj = .ChartObjects.Add(0, 0, AireImage.Width, AireImage.Height)
With ShChObj
.Chart.Paste
.Chart.Export RepertoireImage & NomDeLImage, "jpg"
.Delete
End With
CelluleLien.ClearContents
.Hyperlinks.Add Anchor:=CelluleLien, Address:=RepertoireImage & NomDeLImage, TextToDisplay:=NomDeLImage
Set ShChObj = Nothing
End With
End Sub |
Partager