|
代码参考
Sub test()
tm = Timer
Dim shp As Shape, chtObj As ChartObject
Set fso = CreateObject("scripting.filesystemobject")
With Sheet1
Set chtObj = .ChartObjects.Add(0, 0, 1, 1)
Set oWShell = CreateObject("WScript.Shell")
sDesktopPath = oWShell.SpecialFolders("Desktop")
sDesktopPath = sDesktopPath & "\图片\"
If Not fso.FolderExists(sDesktopPath) Then fso.createfolder (sDesktopPath)
For Each shp In .Shapes
If shp.TopLeftCell.Column = 4 Then
With chtObj
.Width = shp.Width: .Height = shp.Height
shp.CopyPicture
.Chart.ChartArea.Fill.Visible = False
.Chart.ChartArea.Border.LineStyle = xlLineStyleNone
.Select
.Chart.Paste
.Chart.Export sDesktopPath & shp.TopLeftCell.Offset(0, -3) & ".jpg"
End With
End If
Next
End With
chtObj.Delete
Beep
MsgBox "共耗时:" & Timer - tm & "秒!!"
End Sub
|
|