导航到PowerPoint加载项中的特定幻灯片

时间:2017-03-23 21:49:01

标签: c# vsto powerpoint add-in

使用以下代码,我设法跳转到SlideShow中的特定幻灯片 - 查看using code from this question

Microsoft.Office.Interop.PowerPoint.Presentation objPres;
Microsoft.Office.Interop.PowerPoint.SlideShowView objSlideShowView;

objPres = Globals.ThisAddIn.Application.ActivePresentation;
objPres.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
objPres.SlideShowSettings.Run();
objSlideShowView = objPres.SlideShowWindow.View;                

int index = Int32.Parse(clickedIssue.ToolTip.ToString());               

objSlideShowView.GotoSlide(index);

但我真正想要的是它跳转到普通视图中的特定幻灯片。我知道我可以使用Globals.ThisAddIn.Application.ActiveWindow.Application.ActiveWindow.View.Slide获取当前选定的幻灯片,但如何使用代码更改其引用?

2 个答案:

答案 0 :(得分:0)

使用此代码解决它:

Microsoft.Office.Interop.PowerPoint.Presentation objPres;
int index = Int32.Parse(clickedIssue.ToolTip.ToString());

objPres = Globals.ThisAddIn.Application.ActivePresentation;
var slides = objPres.Slides;

slides[index].Select();

the code from this answer相同。

答案 1 :(得分:0)

我强烈建议使用

int SlideIndex = 3;
try
{
  Globals.YourAddin.Application.ActiveWindow.View.GotoSlide(SlideIndex);
}
catch { }

.Select()引起了一些奇怪的问题,PowerPoint的性能降低了。