How to solve “You can’t set chart effects on objects that are not charts” error?
The following code is taken from https://learn.microsoft.com/en-us/office/vba/api/powerpoint.animationsettings.chartuniteffect
Private Sub Macro1()
'Delete all slides
For i = ActivePresentation.Slides.Count To 1 Step -1
ActivePresentation.Slides(i).Delete
Next i
'Add a blank slide
ActivePresentation.Slides.Add Index:=1, Layout:=ppLayoutBlank
'Add a Chart
With ActivePresentation.Slides(1).Shapes.AddChart(Type:=xlColumnClustered, Left:=0, Top:=0, Width:=400, Height:=200)
.Name = "myChart"
With .Chart.SeriesCollection(1)
.Interior.Color = RGB(255, 0, 0)
.ApplyDataLabels Type:=xlDataLabelsShowLabel
.HasDataLabels = True
.DataLabels.ShowLegendKey = True
.DataLabels.Type = xlValue
.XValues = Array(1, 3, 5, 7, 9)
.Values = Array(2, 3, 5, 12)
End With
End With
'Check if shape type is Chart
If ActivePresentation.Slides(1).Shapes("myChart").Type = msoChart Then
Debug.Print ActivePresentation.Slides(1).Shapes("myChart").Type
End If
'Add a animation to myChart
'The following code taken from https://learn.microsoft.com/en-us/office/vba/api/powerpoint.animationsettings.chartuniteffect
With ActivePresentation.Slides(1).Shapes("myChart")
With .AnimationSettings
'The following line throws this error: "AnimationSetting (unknown member): Invalid request. Sorry, you can't set chart effects on objects that are not charts."
.ChartUnitEffect = ppAnimateBySeries
.EntryEffect = ppEffectFlyFromLeft
.Animate = True
End With
End With
End Sub
Animate a chart by series in PowerPoint using VBA