【问题标题】:How to add a custom slide before and after the first slide in PowerPoint如何在 PowerPoint 中的第一张幻灯片之前和之后添加自定义幻灯片
【发布时间】:2014-07-09 22:22:14
【问题描述】:

我创建了一个 Office 加载项,我需要在其中通过单击自定义按钮将幻灯片添加到演示文稿中。

现在,如果用户在幻灯片预览窗格(即左侧窗格)中单击顶部(在第一张幻灯片之前),则应将新的自定义幻灯片添加到第一个位置。但是,如果用户在任意两张幻灯片之间进行选择,则应在其间添加新的自定义幻灯片。

我正在尝试以下代码:

if (insertNextSlideHere == 0)
{
                slide = Globals.ThisAddIn.Application.ActivePresentation.Slides.Add(1, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
}
else if (Globals.ThisAddIn.sldIndexVal == 0 && Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex == 1)
{
                slide = Globals.ThisAddIn.Application.ActivePresentation.Slides.Add(Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
slide.MoveTo(1);
}
else if (Globals.ThisAddIn.sldIndexVal == 0 && Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex > 1)
{
MessageBox.Show("loop1");
slide = Globals.ThisAddIn.Application.ActivePresentation.Slides.Add(Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex + 1, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);                    

}
else if (Globals.ThisAddIn.sldIndexVal == 0)
{
MessageBox.Show("loop2");
slide = Globals.ThisAddIn.Application.ActivePresentation.Slides.Add(Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
slide.MoveTo(2);

}
else
{
MessageBox.Show("loop3");
slide = Globals.ThisAddIn.Application.ActivePresentation.Slides.Add(Globals.ThisAddIn.Application.ActivePresentation.Windows[1].Selection.SlideRange[1].SlideIndex +1, 
Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank);
}

但是,我基本上不知道如何区分鼠标点击顶部和两张幻灯片之间的时间。

请参考附图和帮助。) 谢谢!

【问题讨论】:

    标签: c# vsto powerpoint add-in


    【解决方案1】:

    更改视图然后更改回来。如果光标在幻灯片 2 和 3 之间,当您返回原始视图时,它会在 2 上。

    例如,在 VBA 中你会:

    Dim lCurrentView As Long
    ' save the current view 
    lCurrentView = ActiveWindow.ViewType
    ' switch views
    ActiveWindow.ViewType = ppViewNotesPage
    ' switch back
    ActiveWindow.ViewType = lCurrentView
    ' and now add a slide after the current slide
    

    另一个似乎有效的技巧(仅当您处于普通视图时):

    For x = 1 To ActiveWindow.Panes.Count
        Debug.Print ActiveWindow.Panes(x).ViewType
        ActiveWindow.Panes(x).Activate
    Next
    

    问题:如果光标位于第一张幻灯片之前或幻灯片 1 和 2 之间,两种方法都会选择第一张幻灯片。这样就很难判断光标是在幻灯片 1 和 2 之间还是在幻灯片 1 之前。

    我不确定如何解决这个问题,除了可能通过向窗口发送箭头键。丑陋。

    【讨论】:

      猜你喜欢
      • 2017-05-02
      • 1970-01-01
      • 2017-11-02
      • 1970-01-01
      • 1970-01-01
      • 2013-08-24
      • 2018-01-12
      • 2021-10-12
      • 1970-01-01
      相关资源
      最近更新 更多