如何更改从PowerPoint的c#加载项显示的当前幻灯片

本文关键字:显示 幻灯片 加载项 何更改 PowerPoint | 更新日期: 2023-09-27 18:26:43

我正试图使用c#加载项来控制PowerPoint当前幻灯片(从IR遥控器双向滑动),但我被的电源点加载项的编程部分卡住了

因此,尽管很简单,我有一个无限循环等待后台线程上的串行命令(完成了这一部分),但我坚持如何更改显示的当前幻灯片

我使用的是office插件->powerpoint 2013插件

如何更改从PowerPoint的c#加载项显示的当前幻灯片

如何更改当前显示的幻灯片

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事件中连接一些事件,然后按照此示例说明如何使用对象模型来显示"下一张幻灯片"。