【发布时间】: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