Sub mImage() Dim wsSheet As Worksheet, oRange As Range, oCht As Chart, oImg As Picture Application.ScreenUpdating = False On Error Resume Next Sheets("mGraf").Select If ActiveSheet.Name = "mGraf" Then Application.DisplayAlerts = False ActiveWindow.SelectedSheets.Delete Application.DisplayAlerts = True End If Set oRange = Range("A1:E30") '<<<< VARIARE Set oCht = Charts.Add oCht.Name = "mGraf" oRange.CopyPicture xlScreen, xlPicture oCht.Paste filepath = "c:\miefoto\" '<<<< VARIARE oCht.Export Filename:=filepath & "MyPic.jpg", FilterName:="jpg" '<<<< VARIARE NOME Application.DisplayAlerts = False ActiveWindow.SelectedSheets.Delete Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub
Sub CopyRangeToJPG() Dim rng As Range, Cht As ChartObject strPath = "D:\DATI\prova\" Set rng = Range("A1:G7") rng.CopyPicture xlScreen, xlPicture Set Cht = ActiveSheet.ChartObjects.Add(0, 0, rng.Width, rng.Height) Cht.Chart.Paste Cht.Chart.Export strPath & "myfile.jpg" Cht.Delete Set Cht = Nothing Set rng = Nothing End Sub