How to find current slide in Powerpoint Slideshow Window

泪湿孤枕 提交于 2019-12-13 09:05:20

问题


I create a Powerpoint add-in and I need to find which slide is active in Slideshow Window. I have this code:

if (Globals.ThisAddIn.Application.SlideShowWindows.Count > 0)
{
for (int s = 0; s < Globals.ThisAddIn.Application.ActivePresentation.Slides.Count; s++)
{
//abc
}
}

So I check if slideshow window is running and then go through all slides in presentation. But this is not very good solution. I want to get current slide immediately.


回答1:


Here's the VBA to do what you want. It returns the index of the active slide in the first slideshow window:

SlideShowWindows(1).View.Slide.SlideIndex



回答2:


I tried this code .this is working for me..It may useful for new developers.

Microsoft.Office.Interop.PowerPoint.Presentation objPres;
                Microsoft.Office.Interop.PowerPoint.SlideShowView oSlideShowView;
                objPres = Globals.ThisAddIn.Application.ActivePresentation;
                objPres.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
PowerPoint.Slide curSlide_1 = ppApp.ActiveWindow.View.Slide;
                objPres.SlideShowSettings.Run();
                oSlideShowView = objPres.SlideShowWindow.View;                
                oSlideShowView.GotoSlide(curSlide_1.SlideIndex);


来源:https://stackoverflow.com/questions/23858619/how-to-find-current-slide-in-powerpoint-slideshow-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!