PDA

View Full Version : How to copy and paste formatting of chart in PowerPoint by vba



ratanbhushan
01-02-2017, 02:11 AM
Hi Team

Is there any way to copy the formatting and pasting it to another chart by VBA in powerpoint?

I am unable to seek any manual way also, please suggest if there is anyways?

Thanks and Regards
RatanB

John Wilson
01-04-2017, 09:08 AM
You can't copy / paste chart format but assuming they are the same type of chart you could save a chart template from chart 1 and apply it chart 2.

This is just the bare bones of the code:


Sub formatCHT()
Dim ocht1 As Chart
Dim ocht2 As Chart
Set ocht1 = ActiveWindow.Selection.ShapeRange(1).Chart
Set ocht2 = ActiveWindow.Selection.ShapeRange(2).Chart
ocht1.SaveChartTemplate ("C:\chart1.crtx")
ocht2.ApplyChartTemplate ("C:\chart1.crtx")
End Sub