How to Change PowerPoint Chart Size and Position using VBA
Question details
The user needs to properly resize and center a chart on a PowerPoint slide using VBA without triggering layout errors.

- Product
- PowerPoint
- Device & OS
- not provided
- Scenario
- Automating presentation layouts using VBA to adjust chart dimensions and center them automatically.
- Observed behavior
- Using the ChartArea.Height property resizes the internal plot area rather than the actual chart object container, resulting in visual errors and an inability to correctly scale the chart.
Ensure your presentation is open, the Developer tab is enabled to access the VBA editor, and you know the name or index of the chart shape you intend to modify.
Use the Shape Object to Resize and Center the Chart
Target the parent Shape object containing the chart to properly alter its outer dimensions and adjust its position on the slide.
When attempting to resize a chart in PowerPoint via VBA, modifying the ChartArea properties will only affect the inner boundaries of the chart inside its container. To scale the entire chart object and avoid structural errors, you must manipulate the Shape object itself.
To perfectly center the chart, calculate the middle of the slide by subtracting the chart's width and height from the slide's total width and height, then dividing the result by two.
Press ALT + F11 in PowerPoint to open the VBA Editor, and insert or select the module where you are writing your formatting macro.
Set a variable for your chart's shape (e.g., Set shp = myPresentation.Slides(1).Shapes("Chart 1")) to directly target the object container.
Adjust the overall size of the chart by changing the shape's properties, for example: shp.Height = 432 and shp.Width = 600.
Apply the centering formula to the Top property: shp.Top = (myPresentation.PageSetup.SlideHeight - shp.Height) / 2.
Apply the centering formula to the Left property: shp.Left = (myPresentation.PageSetup.SlideWidth - shp.Width) / 2.

Automate Presentations with WPS Presentation
WPS Office provides robust VBA and Macro support in its premium versions, allowing you to seamlessly run presentation scripts to resize, position, and format your charts without layout errors.
- 1. Download and Install WPS Office: Download WPS Office from the official website and open WPS Presentation.
- 2. Open Your Macro-Enabled File: Open your .pptm presentation file and navigate to the Developer tab on the ribbon.
- 3. Run Chart VBA Macros: Click on 'Macros' to access the VBA editor, where you can paste and execute your chart resizing and centering scripts flawlessly.

Frequently Asked Questions
Why does using ChartArea.Height cause errors in my PowerPoint macro?
The ChartArea property refers exclusively to the internal plotted area of the chart. Modifying its size independently of its parent container (the Shape object) causes the internal layout to break or throw out-of-bounds errors. You should always use the Shape object's Height and Width properties instead.
How do I align a chart exactly in the middle of a PowerPoint slide using VBA?
To center a chart, you need to use the slide's dimensions and the chart's dimensions. Set the Shape.Top property to '(SlideHeight - Shape.Height) / 2' and the Shape.Left property to '(SlideWidth - Shape.Width) / 2'.
What should I do if my VBA code runs but the chart doesn't look updated?
If the chart is bound to a slide layout placeholder that has been manually adjusted, the macro's size changes may conflict with the layout rules. Go to the Home tab and click 'Reset' to clear manual formatting and allow the macro's properties to take effect.




