2
如何使用COM以編程方式從PowerPoint文件中提取所有圖像?使用COM從PowerPoint中提取所有圖像
如何使用COM以編程方式從PowerPoint文件中提取所有圖像?使用COM從PowerPoint中提取所有圖像
好吧,有兩種方法。其中之一僅適用於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
這看起來不錯,但我無法測試它!,導出功能(sh.Export)不受支持,我導入Microsoft.Office.Interop.PowerPoint版本15,任何請提示? – 2014-06-28 09:48:57
從網上抄襲剛:http://visualbasic.ittoolbox.com/groups/technical-functional/visualbasic-l/export-msoshapetype-msolinkedoleobject-from-powerpoint-47712 HTTP ://msdn.microsoft.com/en-us/library/aa201189 http://msdn.microsoft.com/en-us/library/aa201366 PictureFormat和OLEFormat對於每個ImageShape在ActiveSheet.Shapes'做一些形狀(或許確定它是一個圖像?下一個ImageShape – rwong 2010-07-05 21:14:01