The reason it is failing for your specific sample is that the first shape is a placeholder. In your macro it checks to see if the shape is a placeholder and skips over it if it is. I don't know why the macro was written this way. Irrelevant if you replace it with another shape then it works.
Incorrect operation of the Visual Basic script in the PowerPoint slides
Hello community. I need your help.
In my work I need to export shapes from PowerPoint slides. Since it is boring to do it manually (by selecting the "save as image" option) I use the MVB script (found here in another thread).
Sub ExportShapesAsPNGs()
Dim sld As Slide
Dim shp As Shape
Dim path As String
Dim name As String
Dim i As Integer
path = "
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.Type <> msoPlaceholder Then
i = i + 1
name = sld.name & "_" & i & ".png"
shp.Export path & name, ppShapeFormatPNG
End If
Next shp
Next sld
MsgBox i & " shapes exported as PNGs."
End Sub
It worked perfectly. Until I came across a slide from which it flatly refused to export a specific shape. It exports all shapes except one. This top shape with the text "Test" in yellow. The bottom shape "Test2" is exported as png without problems. Both shapes are exported without problems when choosing the "save as image" option. What is not working as expected in this script?
Link to the tested slide on Dropbox: https://www.dropbox.com/scl/fi/ifv278qx0ng4zg1nebzn2/Test.pptx?rlkey=0o2mjyhgf72tsugrfv45m7zm1&st=zqok53e9&dl=0