Option Explicit
Sub test ()
Dim fichier$, dossier$
dossier = "D:\Mon Dossier" '<--- ici le chemin du dossier où sauvegarder
If Dir(dossier, vbDirectory) = "" Then MkDir (dossier)
fichier = "ABC" & Format(Date, " dd mmmm yyyy") & ".jpg"
ExportRangeInImage [Feuil1!C1:Y34], dossier & "\" & fichier
End Sub
Sub ExportRangeInImage(plage As Range, CheminX As String)
Dim chart1 As Object, hPicAvail As Long
Set chart1 = plage.Parent.ChartObjects.Add(0, 0, 1, 1).Chart
With CreateObject("htmlfile").parentwindow.clipboardData.clearData("Text"): End With 'on vide le clipboard entre chaque copie pour tester vraiment le available
With chart1
With .Parent
.Width = plage.Width: .Height = plage.Height: .Left = plage.Width + 20:
plage.CopyPicture
Do: DoEvents
hPicAvail = ExecuteExcel4Macro("CALL(""user32"",""IsClipboardFormatAvailable"",""JJC""," & 14 & ")") '2 pour bitmap,14 pour wmf
Loop While hPicAvail = 0
.Select
.Chart.Paste
Do: DoEvents: Loop While .Chart.Pictures.Count = 0
.Chart.Export CheminX, "jpg"
.Chart.Pictures(1).Delete 'on delete a chaque fois l'image collée (important si les plages capturées sont differentes en terme de dimension)
End With
End With
chart1.Parent.Delete
End Sub