簡體   English   中英

如何更改PowerPoint的c#加載項中顯示的當前幻燈片

[英]how to change current slide shown from c# Add-in for PowerPoint

我正在嘗試使用c#add-in來控制PowerPoint當前幻燈片(從IR遙控器雙向滑動)但我仍然停留在電源插件的編程部分

所以很簡單,我有一個無限循環等待后台線程上的串行命令(完成這部分),但我堅持如何更改當前顯示的幻燈片

我正在使用辦公室加載項 - > power point 2013加載項

如何更改當前顯示的幻燈片?

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事件中連接一些事件,然后按照此示例說明如何使用對象模型來顯示Next Slides。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM