简体   繁体   English

Powerpoint VSTO如何将幻灯片插入部分

[英]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处插入一张幻灯片,但就目前而言,该幻灯片将最终显示在“标题页”下方。

  • Default Section 默认部分
    • Header Page 标题页
  • Section 1 第一节
    • Page 1 第1页
    • Page 2 第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.

相关问题 如何使用OpenXML在powerpoint幻灯片中插入形状 - How to insert a shape in a powerpoint slide using OpenXML 如何使用C#VSTO读取presentationML并将输出放置在PowerPoint的活动幻灯片上 - How to read presentationML and place the output on Active slide of powerpoint using c# VSTO 如何在 PowerPoint VSTO c# 加载项中创建 function 加载项,它将当前幻灯片更改为下一张幻灯片,我该如何测试它? - how to create a function in PowerPoint VSTO c# Add-in which will change the current slide to the next slide and how can I test it? 使用VSTO外接程序在PowerPoint 2016中的幻灯片上添加WebBrowser - Adding a WebBrowser on a slide in PowerPoint 2016 using a VSTO AddIn C#PowerPoint VSTO:检查是否有任何幻灯片在视图中 - C# PowerPoint VSTO: Check if Any Slide is in View 如何在powerpoint幻灯片中格式化文本框 - How to format textbox in powerpoint slide VSTO-如何获取PowerPoint模板文件夹? - VSTO - How to get PowerPoint template folder? VSTO Powerpoint AddIn - 如何将图片添加到幻灯片 - VSTO Powerpoint AddIn - how to Add Picture to sliede 如何在PowerPoint中以编程方式更改幻灯片布局? - How to change slide layout programmatically in PowerPoint? 如何将powerpoint幻灯片嵌入网页 - how can i embed a powerpoint slide into a webpage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM