|
Sub test()
Dim p, i, x, y
p = ThisWorkbook.Path & "\"
For i = 1 To Sheets(1).Shapes.Count
Set x = Sheets(1).Shapes(i)
Set y = Cells(1, i + 1)
With x
.Left = y.Left
.Top = y.Top
.Width = y.Width
.Height = y.Height
Call Chart2Pic(x, p & y.Offset(1, 0) & ".jpg")
End With
Next i
End Sub
'导出图片(对象, 路径)
Sub Chart2Pic(x, f)
x.CopyPicture Appearance:=xlScreen, Format:=xlBitmap '将所选对象作为图片复制到剪贴板
With ActiveSheet.ChartObjects.Add(0, 0, x.Width, x.Height).Chart '创建嵌入式图表
.Paste '将剪贴板中的图表数据粘贴到指定的图表中
.Export Filename:=f '以图形格式导出图表
.Parent.Delete
End With
End Sub
含图片文件4.rar
(219.51 KB, 下载次数: 24)
|
|