|
Sub ExtractPictures()
Dim shp As Shape
Dim i As Integer
Dim sPath As String
Dim sFileName As String
Dim sExtension As String
Dim sNewFileName As String
sPath = ThisWorkbook.Path & "\"
sFileName = Left(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, ".") - 1)
For Each shp In ActiveSheet.Shapes
If shp.Type = msoPicture Then
i = i + 1
sExtension = "." & Right(shp.Name, Len(shp.Name) - InStrRev(shp.Name, "."))
sNewFileName = sPath & sFileName & "_" & i & sExtension
shp.CopyPicture
With New Chart
.Paste
.Export sNewFileName, "JPG"
.Parent.Delete
End With
End If
Next shp
End Sub |
|