Avatar of netfriendsinc
netfriendsinc

asked on 

Export all charts on a sheet, Excel 2016 for Mac

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:

Sub Button_Click()
    Dim cht As ChartObject
        For Each cht In ActiveSheet.ChartObjects
            cht.Export ActiveWorkbook.Path & Application.PathSeparator & cht.Name & ".png"
        Next cht
End Sub

When I run this code, I get "Compile error:

Method or data member not found
(Module1 3:15)"

If I do "cht.Chart.Export" instead of "cht.Export," I get error 70, permission denied.

Also tried this:

For i = 1 To 9
ActiveSheet.ChartObjects(i).Select
ActiveChart.Export ActiveWorkbook.Path & Application.PathSeparator & ActiveChart.Name & ".png", "PNG"
Next i

Got error 70, permission denied.
Microsoft ExcelVBAMac OS X

Avatar of undefined
Last Comment
netfriendsinc

8/22/2022 - Mon