jpsnow72
jpsnow72

Reputation: 995

C# Save PPT Shape (msoPicture) as Image w/ Office.Interop

I have a PPT slide deck with multiple images. I am iterating through each slide and each shape. I would like to save each shape of type msoPicture as an Image:

            foreach (PPT.Slide slide in pptDoc.Slides)
            {
                foreach (PPT.Shape shape in slide.Shapes)
                {
                    if (shape.Type == Microsoft.Office.Core.MsoShapeType.msoPicture)
                    {

                        Image img;
                        //???? Save shape as image
                        img.Save(filename);
                    }
                }
            }

Upvotes: 0

Views: 2170

Answers (1)

bassfader
bassfader

Reputation: 1356

You can use the Shape.Export() method to create an image from an individual shape.

For example like this:

foreach (PPT.Slide slide in pptDoc.Slides)
{
    foreach (PPT.Shape shape in slide.Shapes)
    {
        if (shape.Type == Microsoft.Office.Core.MsoShapeType.msoPicture)
        {
            shape.Export(filename, Microsoft.Office.Interop.PowerPoint.PpShapeFormat.ppShapeFormatPNG);
        }
    }
}

Upvotes: 1

Related Questions