如何更改从 C# Add-in for PowerPoint 显示的当前幻灯片

use*_*832 3 c# powerpoint add-in

我正在尝试使用 C# 插件来控制 PowerPoint 当前幻灯片(从红外遥控器双向滑动),但我陷入了 Power Point 插件的编程部分

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

我正在使用 Office 加载项 -> Power Point 2013 加载项

Jer*_*son 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();
}
Run Code Online (Sandbox Code Playgroud)

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