کد زیر رنج اختصاص داده شده را در مسیر خود فایل و با نام تاریخ و ساعت ذخیره می کند :
کد:
Sub M_E()
Dim pt As String
Dim i As Integer
Dim intCount As Integer
Dim objPic As Shape
Dim objChart As Chart
Call Sheets(1).Range("A1:E8").CopyPicture(xlScreen, xlPicture)
Sheets(1).Shapes.AddChart
Sheets(1).Shapes.Item(2).Select
Set objChart = ActiveChart
Sheets(1).Shapes.Item(2).Width = Range("A1:E8").Width
Sheets(1).Shapes.Item(2).Height = Range("A1:E8").Height
objChart.Paste
pt = ThisWorkbook.Path & "\" & Format(Date, "yyyymmdd") & "-" & Format(Time, "hhmmss") & ".Jpeg"
objChart.Export (pt)
shpCount = Sheets(1).Shapes.Count
For i = 1 To shpCount
If Mid(Sheets(1).Shapes.Item(i).Name, 1, 5) = "Chart" Then
Sheets(1).Shapes.Item(i).Delete
End If
Next i
End Sub
Leave a comment: