如何在C#的PowerPoint插件中切换当前幻灯片显示

3
我正在尝试使用C#插件控制PowerPoint当前幻灯片(通过IR遥控器双向幻灯片),但在编程PowerPoint插件的部分卡住了。
所以,简单来说,我在后台线程上等待串行命令的无限循环(已完成此部分),但我不知道如何更改当前显示的幻灯片。
我正在使用Office插件 -> PowerPoint 2013插件。

1
https://dev59.com/z07Sa4cB1Zd3GeqP0Q4q#2922544 - Kristian Damian
1个回答

5
如何更改当前显示的幻灯片?
Microsoft.Office.Interop.PowerPoint.Application objPPT;
Microsoft.Office.Interop.PowerPoint.Presentations objPresentations;
Microsoft.Office.Interop.PowerPoint.Presentation objCurrentPresentation;
Microsoft.Office.Interop.PowerPoint.SlideShowView objSlideShowView;

private void StartPowerPointPresentation(object sender, EventArgs e)
{
    // Open an instance of PowerPoint and make it visible to the user
    objPPT = new Microsoft.Office.Interop.PowerPoint.Application();
    objPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;

    //Open a presentation
    OpenFileDialog openDlg = new OpenFileDialog();
    openDlg.Filter = "Powerpoint|*.ppt;*.pptx|All files|*.*";
    if (opendlg.ShowDialog() == true)
    {
        //Open the presentation
        objPresentations = objPPT.Presentations;
        objCurrentPresentation = objPresentations.Open(openDlg.FileName, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
        //Hide the Presenter View
        objCurrentPresentation.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
        //Run the presentation
        objCurrentPresentation.SlideShowSettings.Run();
        //Hold a reference to the SlideShowWindow
        objSlideShowView = objCurrentPresentation.SlideShowWindow.View;
    }
}

private void ShowNextSlide(object sender, EventArgs e)
{
    //Unless running on a timer you have to activate the SlideShowWindow before showing the next slide
    objSlideShowView.Application.SlideShowWindows[1].Activate();
    //Go to next slide
    objSlideShowView.Next();
}

这在AddIn中应该很容易实现,您可能需要在StartUp事件中连接一些事件,然后按照以下示例使用对象模型来显示下一张幻灯片。


@AndrewxXx,你搞定了吗?如果需要任何澄清的地方,请告诉我并颁发悬赏。干杯! - Jeremy Thompson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接