简体   繁体   中英

PowerPoint Interop - Start presentation with slide index (not fullscreen) with C#

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?

简报设定

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM