How to change the current slide shown with C # Add-in for PowerPoint

I'm trying to use a C # add-in to control the current PowerPoint slide (to slide in both directions from the IR remote), but I'm stuck on the programming part for the power point add-in

as simple as it is im having an infinite loop waiting for serial commands on the background thread (done by this part) but im stuck on how to change the currently displayed slide

I am using Office Add-ins -> Power Point Add-in 2013

+3


source to share


1 answer


How do I change the currently displayed slide?

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();
}

      



This should be easy to implement in AddIn, you might need to hook up some events in the StartUp event and then follow this example on how to use the object model to display the next slides.

+4


source







All Articles