2
votes

How to set the Presentations or slide(PPT) pagsize in PowerPoint using C# interop library?

I want to set the Presentations pagsize is "ppSlideSizeOnScreen16x9"

     // Create new Slide
        PowerPoint.Application pptApp = new PowerPoint.Application();
        MyPres = pptApp.Presentations.Add(MsoTriState.msoFalse);
        MyPres.Final = false;
        MyPres.PageSetup.SlideSize = PowerPoint.PpSlideSizeType.ppSlideSizeOnScreen16x9;

        Code more ...

This result is not what I expected ; Now, how to set the Presentations or slide(PPT) pagsize?

2

2 Answers

1
votes

Not sure if this is exactly what you're looking for, but it's how I've been setting the slide size.

this.Application.ActivePresentation.PageSetup.SlideHeight = <your slide height>;
this.Application.ActivePresentation.PageSetup.SlideWidth = <your slide width>;

Allows you to set the width and height of the slide in points, not pixels. You can use the below to convert pixels to points

private int PixelsToPoints(int pixels)
{
     return pixels * 72 / 96;
}
0
votes

now,this is right code:

        PowerPoint.Application pptApp = new PowerPoint.Application();
        MyPres = pptApp.Presentations.Add(MsoTriState.msoTrue);
        MyPres.PageSetup.SlideWidth = <slide width>;
        MyPres.PageSetup.SlideHeight = <slide height >;

This line of code have bug?, I'm not sure !!

        MyPres.PageSetup.SlideSize = PowerPoint.PpSlideSizeType.ppSlideSizeOnScreen16x9;