Domanda

I'm using the code below to start a presentation in C#:

    var app = new Microsoft.Office.Interop.PowerPoint.Application();
    var pres = app.Presentations;            
    Presentation objPres = pres.Open(@"C:\test.pptx", MsoTriState.msoTrue, MsoTriState.msoTrue);
    objPres.SlideShowSettings.Run();

How can I start the presentation from a custom start index? Let's say the 4th slide.

How can I start the presentation with a custom window size (standard is fullscreen)? Please check the image below - with these settings the presentation is started in a window. How can I set these values through the interops?

Powerpoint Settings

È stato utile?

Soluzione

This is how you'd do it in VBA. It should be simple enough to adapt to .Net. It's just a matter of setting a few properties before invoking the .Run method.

Sub Example()

    With ActivePresentation.SlideShowSettings

        ' display a range of slides:
        .RangeType = ppShowSlideRange

        ' Start with slide 5
        .StartingSlide = 5

        ' Specify the ending slide or as here,
        ' have it run to the end of the presentation:
        .EndingSlide = ActivePresentation.Slides.Count

        ' window, not fullscreen/kiosk:
        .ShowType = ppShowTypeWindow

        ' and show it:
        .Run

    End With

End Sub
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top