Martin
Martin

Reputation: 1622

Centering a Shape using VBA in PowerPoint 2003

I am programatically copying tables and graphs from Excel to PowerPoint.

Ideally, I'd like to center the graphs on the slide and resize them to fit the slide if necessary.

This shouldn't be too hard, and I can check & modify .Top, .Left, .Width, .Height of the shape just fine, but how do I find out the width/height of the slide itself to do the proper positioning?

Upvotes: 3

Views: 3082

Answers (1)

Dr. belisarius
Dr. belisarius

Reputation: 61016

The following will give you the Height and Width ...

Just divide by 2 :D

Sub a()
   Dim a As Presentation
   Set a = ActivePresentation
   MsgBox a.PageSetup.SlideHeight, a.PageSetup.SlideWidth
End Sub

HTH

Upvotes: 2

Related Questions