OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

Determine the shape type contained in a placeholder

In previous version you would rely on various hacks to figure out what was the type of shape that the placeholder was containing. Especially when you want to determine whether the shape contained a table, chart, diagram etc. Various properties were introduced like HasChart, HasTable etc to mitigate this issue. In PPT 2007 this is a cake walk, thanks to a new property which returns the exact shape type contained in the placeholder.

To try this example:

1. Create slide with the title and content layout.

2. Run the macro.

3. Add a SmartArt within the content placeholder and run the macro again.


Sub CheckContainedType()

     Debug.Print ActivePresentation.Slides(1).Shapes.Placeholders(1).PlaceholderFormat.ContainedType

     Debug.Print ActivePresentation.Slides(1).Shapes.Placeholders(2).PlaceholderFormat.ContainedType

End Sub 

Check the results in the immediate window the first time around and then the second time around. Initially the 2nd placeholder will return 1 since it has no content so effectively it is a regular shape. But when the smartart content is introduced in the placeholder, it returns 24 which is the enum value of a smartart when you run the macro a 2nd time.


Copyright 1999-2022 (c) Shyam Pillai. All rights reserved.