如何使用COM以编程方式从PowerPoint文件中提取所有图像?
答案 0 :(得分:2)
嗯,有两种方法。其中一个仅适用于PowerPoint 2007和2010。但是:
COM中的方式是通过名为Shape.Export
的折旧功能。为了访问它的Intellisense,您必须在VBE中选择“显示隐藏成员”(假设您正在使用VBA)。以下是使用它的代码:
Sub SaveAllPictures()
Dim ap As Presentation: Set ap = ActivePresentation
Dim savePath As String
savePath = "C:\Users\me\Desktop\files\"
Dim i As Integer
Dim sl As Slide
Dim sh As Shape
For Each sl In ap.Slides
For Each sh In sl.Shapes
If sh.Type = msoPicture Then
sh.Export PathName:=savePath & sh.Name & CStr(i) & ".png", Filter:=ppShapeFormatPNG
i = i + 1
End If
Next
Next
End Sub