0
votes

Trying to programmatically create a POWERPOINT template/design using VSTO C# and I was wondering how can I set where the elements should be place? Like the Title should be at the corner top most of the slide and the table should be under it.

I've been searching but to my dismay can't find any solution.

Thank you in advance!

1
The placeholders are all shapes on one of the layouts belonging to a slide master (or Design, as it's described in the object model). Each shape has top, left, height and width properties that determine its placement.Steve Rindsberg

1 Answers

0
votes

Pretty much as Steve said. So, first something like -

PowerPoint.CustomLayout customLayout;
customLayout = presentation.SlideMaster.CustomLayouts[1];
slide = slides.AddSlide(slideIndex, customLayout);

You can always change the layout again to something different -

slide.Layout = PowerPoint.PpSlideLayout.ppLayoutBlank;

Then, you can iterate through shapes like -

 foreach (PowerPoint.Shape shape in shapes)
    {
        if (shape.PlaceholderFormat.Type == PowerPoint.PpPlaceholderType.ppPlaceholderPicture)  
//or ppPlaceholderTitle or ppPlaceholderBody etc
        {
            // Do whatever
        }
    }