I have found, corrected and tested to pieces of code for dealing with charts in Powerpoint.
The first piece is make the plots the same size and position them correctly (assuming there are two plots on the slide) and goes like this:
Sub ProcessAllSlides()
Dim sld As Slide
Dim Shp As Shape
For Each sld In ActivePresentation.Slides
Call SetChartSizeAndPosition(sld.Shapes(1), 30, 120, 320, 240)
Call SetChartSizeAndPosition(sld.Shapes(2), 370, 120, 320, 240)
Next
End Sub
Sub SetChartSizeAndPosition(Shp As Shape, Left As Single, Top As Single, Width As Single, Height As Single)
With Shp
.Left = Left
.Top = Top
.Width = Width
.Height = Height
End With
End Sub
This works on all slides in the presentation. I would like it to only function on the active slide.
The second piece is supposed to format the plot area (and not the chart area). See below:
Sub SizePlotArea()
Dim oSld As Slide
Dim oCht As Chart
Set oCht = ActiveWindow.Selection.ShapeRange(1).Chart
With oCht.PlotArea
' Edit these values as needed
' Change the following lines to e.g. Msgbox .Left etc
' to get the values of the chart you want to match others TO
.Left = 0
.Top = 0
.Height = 220
.Width = 300
End With
End Sub
Idealy I would like to combine the two such that they are done for all (two) charts on the active slide.
Anyone with any tips?