I am coding using PowerPoint VBA, but am having difficulties trying to reliably change the fill colour of a shape (rectangle) using an animation timeline and msoAnimEffectChangeFillColor. What happens is on the first occasion the colour-change works as intended, but doing a repetition on the same shape (normally the second or third run) results in the replacement colour changing to a different undesired colour (normally orange - I believe this is the default colour set by Powerpoint?) I have found this easy to replicate and give an example with code below.
If you create a PowerPoint and insert a filled rectangle and run the below macro (such as when the rectangle is clicked on) - the first click changes to the intended colour (here red). However, if you keep running the macro the colour changes to orange (normally on the third click!) I would be grateful if anyone could explain why this happens and any suggestions for a solution! The other observation I have made is that often I have to reset the PowerPoint in the Visual Basic Editor for the animation to start working again so it fills the rectangle with the intended (red) colour!

Dim oshp As Shape
Dim oeff As Effect
Dim MyDocument As Slide


Sub rectangle()


'This text is not part of the animation but removes any existing animations on the current timeline'
Dim i As Integer
For i = ActivePresentation.Slides(1).TimeLine.MainSequence.Count To 1 Step -1
ActivePresentation.Slides(1).TimeLine.MainSequence(1).Delete
Next i


'This is the code to create the animation.
Set MyDocument = ActivePresentation.Slides(1)
Set oshp = MyDocument.Shapes("Rectangle 3")
Set oeff = MyDocument.TimeLine.MainSequence.AddEffect _
(Shape:=oshp, effectid:=msoAnimEffectChangeFillColor, trigger:=msoAnimTriggerWithPrevious)
oeff.EffectParameters.Color2.RGB = RGB(255, 0, 0)
oeff.Timing.Duration = 0.25
oeff.Timing.TriggerDelayTime = 0.5


End Sub


Thank you for any comments or suggestions!