やりたいこと
PowerPointの各スライドのテキストを取得する。
ソースコード
下記のコードで取得できる。グループ化されたオブジェクトにも対応。
ただし、グラフには未対応。
Module1.bas
Public Sub FindText3()
Dim sld As Slide
Dim sh As Shape
Dim clm As Column
Dim cl As Cell
Dim art As SmartArtNode
Dim grp As GroupShapes
For Each sld In ActivePresentation.Slides
For Each sh In sld.Shapes
'テキストボックス、プレースホルダ、オートシェイプの場合
If sh.HasTextFrame Then
Debug.Print sh.TextFrame.TextRange.text
'表の場合
ElseIf sh.HasTable Then
For Each clm In sh.Table.Columns
For Each cl In clm.cells
Debug.Print cl.Shape.TextFrame.TextRange.text
Next
Next
'グラフの場合
ElseIf sh.HasChart Then
If sh.Chart.HasTitle Then Debug.Print sh.Chart.Title
'スマートアートの場合
ElseIf sh.HasSmartArt Then
For Each art In sh.SmartArt.Nodes
Debug.Print art.TextFrame2.TextRange.text
Next
'グループの場合
ElseIf sh.Type = msoGroup Then
For Each gsh In sh.GroupItems
If gsh.HasTextFrame Then Debug.Print gsh.TextFrame.TextRange.text
Next
End If
Next
Next
End Sub
参考
下記のコードを参考にしました。