[英]Powerpoint VSTO how to insert slide into section
I am working on a Powerpoint addin, that helps with creating agenda slides. 我正在开发一个Powerpoint插件,它有助于创建议程幻灯片。 I have to insert a slide at a specific location, which is easy using presentation.Slides.AddSlide(index, customlayout).
我必须在特定位置插入一张幻灯片,使用presentation.Slides.AddSlide(index,customlayout)很容易。 But since I am also using sections, this always inserts the slide inside the first (default) section.
但是由于我也在使用节,所以总是将幻灯片插入第一个(默认)节中。
Here's an example structure. 这是一个示例结构。 I would like to replace Page 1 at it 's current position.
我想将Page 1替换为当前位置。 For this I would need to insert a slide at slideIndex=2, but as it stands now, the slide will end up below "Header Page".
为此,我需要在slideIndex = 2处插入一张幻灯片,但就目前而言,该幻灯片将最终显示在“标题页”下方。
And here is some code I am using 这是我正在使用的一些代码
private static PPT.Slide RefreshDefaultAgendaFormat(PPT.Presentation presentation, PPT.CustomLayout customAgendaLayout, PPT.Slide currentSlide)
{
int tempindex = currentSlide.SlideIndex;
int tempSectionIndex = currentSlide.sectionIndex;
currentSlide.Delete();
currentSlide = presentation.Slides.AddSlide(tempindex, customAgendaLayout);
return currentSlide;
}
I managed to solve it by changing the order of operations and adding it at the current index+1. 我设法通过更改操作顺序并将其添加到当前索引+1处来解决该问题。
int tempindex = currentSlide.SlideIndex;
int tempSectionIndex = currentSlide.sectionIndex;
PPT.Slide newSlide = presentation.Slides.AddSlide(tempindex + 1, customAgendaLayout);
currentSlide.Delete();
return newSlide;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.