Powerpoint - VBA - Manipulating shapes inside placeholder shapes (via VBA)
-
Saturday, April 21, 2012 11:48 PM
I need to read /write all texts in PPT presentations.
All goes well except for shapes (mostly tables) inside placeholder objects.
I've been trying to find out how to manipulating shapes inside placeholder shapes, but without success.The closest post I've seen to my problem is
http://stackoverflow.com/questions/3568412/powerpoint-getting-the-original-shape-from-inside-a-placeholder-programatical
Mr. Otaku suggested usingSmartArtQuickStyleto get at the object inside the placeholder, but all the documentation I looked at forSmartArtQuickStyle have me no clue.Could someone please give me a clue?
Thanks so much,
JSvendsen
Powerpoint 2010
All Replies
-
Sunday, April 22, 2012 4:57 PM
Hello,
PPT 2007 and later have the ContainedType property on the PlaceholderFormat which will tell you what type of shape is contained within the placeholder. Once you know what type is contained then the rest of the processing is just like any other shape.
Assuming shp has a reference to a placeholder shape then the line below will give you info on the type within it
Debug.Print shp.PlaceholderFormat.ContainedType
To give you a better understanding:
Sub Test()
Dim shp As Shape
Dim sld As SlideSet sld = ActivePresentation.Slides(1)
' Look for placeholders containing tables on the 1st slide of the presentation
For Each shp In sld.Shapes.Placeholders
If shp.PlaceholderFormat.ContainedType = msoTable Then'If we find one pass the shape reference to the routine that is enumerating the text
Call EnumerateTableText(shp)
End If
NextEnd Sub
Sub EnumerateTableText(shp As Shape)
Dim row As Long
Dim column As LongFor row = 1 To shp.Table.Rows.Count
For column = 1 To shp.Table.Columns.Count
Debug.Print shp.Table.Cell(row, column).Shape.TextFrame2.TextRange.Text
Next
NextEnd Sub
Regards, Shyam (http://skp.mvps.org)
- Edited by Shyam PillaiMVP Sunday, April 22, 2012 5:11 PM
- Edited by Shyam PillaiMVP Sunday, April 22, 2012 5:18 PM
- Marked As Answer by Tom_Xu_WXModerator Wednesday, April 25, 2012 6:33 AM

