Reputation: 93
I'm attempting to automate production of a PowerPoint presentation in MS Excel 2016 using VBA. I want to copy a Map Chart based on a PivotTable, and am getting "Run-time error '445': Object doesn't support this action".
I am using Excel 2016. I am trying to copy a Map Chart that is based on a pivot table, and cannot get the chart to 'copy'. I've tried recording a macro, but when I run the recorded code it produces the same error. I've included a simplified version of the code below, which is still producing the error for me. When I apply this code to other graphs (bar or line) in the same worksheet there are no errors.
Sub X()
Dim wb As Workbook
Dim wsa As Worksheet
Dim ch As ChartObject
Set wb = ThisWorkbook
Set wsa = Sheets("World Map")
For Each ch In wsa.ChartObjects
myleft = ch.Left
myright = ch.Top
ch.Copy
Next ch
End Sub
ch.Copy
produces an error. I expected to be able to successfully copy this, and add code to paste it into PowerPoint.
Upvotes: 0
Views: 459
Reputation: 56
Did you try using "ch.CopyPicture" instead of "ch.Copy"? It worked for me.
Sub X()
Dim wb As Workbook
Dim wsa As Worksheet
Dim ch As ChartObject
Set wb = ThisWorkbook
Set wsa = Sheets("World Map")
For Each ch In wsa.ChartObjects
myleft = ch.Left
myright = ch.Top
ch.CopyPicture
Next ch
End Sub
Upvotes: 1