Shapes

Collect.Shapes method

Collects all instances of Shape in the Presentation.

public static IEnumerable<Shape> Shapes(Presentation pres)
ParameterTypeDescription
presPresentationPresentation to collect shapes

Return Value

Collection of all shapes that contain in the presentation

Examples

using (Presentation pres = new Presentation("pres.pptx"))
{
    foreach (Shape shape in Collect.Shapes(pres))
    {
        // if the shape is AutoShape, add a black solid border
        if (shape is AutoShape autoShape)
        {
            autoShape.LineFormat.Style = LineStyle.Single;
            autoShape.LineFormat.Width = 10f;
            autoShape.LineFormat.FillFormat.FillType = FillType.Solid;
            autoShape.LineFormat.FillFormat.SolidFillColor.Color = Color.Black;
        }
    }
    
    pres.Save("pres-out.pptx", SaveFormat.Pptx);
}        

See Also