Trying to create a VBA macro button I can click to export all chart objects on a sheet to PNG files in the same directory as the workbook. Charts have names like "Chart 3," "Chart 5," etc. that apparently I can't change.
Here is my current code:
Dim cht As ChartObject
For Each cht In ActiveSheet.ChartObjects
cht.Export ActiveWorkbook.Path & Application.PathSeparator & cht.Name & ".png"
When I run this code, I get "Compile error:
Method or data member not found
If I do "cht.Chart.Export" instead of "cht.Export," I get error 70, permission denied.
Also tried this:
For i = 1 To 9
ActiveChart.Export ActiveWorkbook.Path & Application.PathSeparator & ActiveChart.Name & ".png", "PNG"
Got error 70, permission denied.