Search code examples
vbapowerpoint

Copy ChartArea dimensions from one chart to another in PowerPoint


I'm writing code that copies the formatting from a selected table to a second selected table. I'm having trouble copying the ChartArea dimensions like so:

I get an error 445 'Object doesn't support this action'

The code for this is:

sub copychartarea()
ActiveWindow.Selection.ShapeRange(1).Chart.ChartArea.Top = ActiveWindow.Selection.ShapeRange(2).Chart.ChartArea.Top
end sub

Is there another way to do this?

Thanks


Solution

  • The ChartArea property of the Chart object is read-only, as per the following article...

    https://learn.microsoft.com/en-us/office/vba/api/excel.chart.chartarea

    Try the following instead...

    ActiveWindow.Selection.ShapeRange(1).Top = ActiveWindow.Selection.ShapeRange(2).Top