How to Get the Slide Width in PowerPoint using VBA

When we created our add-in for PowerPoint to export slides as images we faced an interesting challenge. Aside of choosing a specific output size, we needed to get the actual size of the PowerPoint presentation while iterating through each slide. This way we were able to calculate the new width and height (and aspect ratio) in order to export the image with the same proportions that the original slide design.

So, we needed to get the actual size of the PowerPoint slide using VBA and the way we did was accessing a few properties of the PageSetup object for the Active Presentation. This snippet may help you to get the active presentation slides dimensions (width and height) using VBA so you can then export the slides to images from your macros.

ActivePresentation.PageSetup.SlideWidth
ActivePresentation.PageSetup.SlideHeight

Notice that this information is available under the Page Setup object, and not directly from the Active Presentation. Makes sense given that you can change the page setup properties for a given document.

If you want to know the aspect ratio of the PowerPoint presentation using VBA, then you can use the same properties to get the width and height. This aspect ratio calculator is also useful to check the aspect ratio of any image by the width and height values.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Leave a Comment

Your email address will not be published. Required fields are marked *