|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub demo() '导出选中图片
Dim i, shp As Object
On Error GoTo AA
With ActiveSheet
If Selection.ShapeRange.Count > 1 Then
For Each shp In Selection
i = i + 1
shp.Copy
With .ChartObjects.Add(0, 0, shp.Width, shp.Height).Chart
.Parent.Select
.Paste
.Export ThisWorkbook.Path & "\AAA\" & i & ".jpg"
.Parent.Delete
End With
Next
ElseIf Selection.ShapeRange.Count = 1 Then
Set shp = Selection.ShapeRange(1)
shp.Copy
With .ChartObjects.Add(0, 0, shp.Width, shp.Height).Chart
.Parent.Select
.Paste
.Export ThisWorkbook.Path & "\AAA\ 1.jpg"
.Parent.Delete
End With
End If
End With
Exit Sub
AA:
MsgBox "请选择要保存的图形!"
End Sub
请教还哪里不对?请见附件。谢谢!
批量导出选择的图片 - 副本.zip
(379.58 KB, 下载次数: 13)
|
|