簡體   English   中英

Powerpoint VSTO如何將幻燈片插入部分

[英]Powerpoint VSTO how to insert slide into section

我正在開發一個Powerpoint插件,它有助於創建議程幻燈片。 我必須在特定位置插入一張幻燈片,使用presentation.Slides.AddSlide(index,customlayout)很容易。 但是由於我也在使用節,所以總是將幻燈片插入第一個(默認)節中。

這是一個示例結構。 我想將Page 1替換為當前位置。 為此,我需要在slideIndex = 2處插入一張幻燈片,但就目前而言,該幻燈片將最終顯示在“標題頁”下方。

  • 默認部分
    • 標題頁
  • 第一節
    • 第1頁
    • 第2頁

這是我正在使用的一些代碼

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;
    }

我設法通過更改操作順序並將其添加到當前索引+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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM