

Excel VBA
Excel VBA批量导出图片
2017-07-05 16:25:39
有的时候我们需要批量导出图片。有个简单的方法就是通过另存为把图片分离出来。
下面我们来介绍一下如何用VBA一键导出所有图片
如下动态图:
详细源码:
Sub 批量导出图片()
Dim shp As Shape
Dim FileName As String
For Each shp In Sheet1.Shapes
If shp.Type = msoPicture Then
FileName = ThisWorkbook.Path & "\" & shp.Name & ".gif"
shp.Copy
With Sheet1.ChartObjects.Add(0, 0, shp.Width, shp.Height).Chart
.Paste
.Export FileName, "gif"
.Parent.Delete
End With
End If
Next
End Sub