none
Copy animations from Master to Slide PowerPoint RRS feed

  • Question

  • Hello,

    I am a presentation with around 10 slides. First 5 slides have animations that are created within the slides. The other 5 extends the animations from master slide. I want to copy the animations present in the SlideMaster to the current slide. 

     

    As you can see the above image when I go to current Slide-->Animations-->Animation Pane I get the above animation pane. This shows that the animation is from master and current slide extends from the Master.

     

    As you can see in above image there is option to copy effects from master to slide. once I copy the slide looks and animation pane looks like as shown below.

    I want to do this using c# coding. I have tried different things but unable to copy the animation from master to slide. Please help


    mehulviby

    Thursday, December 17, 2015 10:05 AM

Answers

  • >>>I want to do this using c# coding. I have tried different things but unable to copy the animation from master to slide. Please help

    PowerPoint 2010 and later has new methods to clone animations, you could refer to below VBA code then change them into c#:

    Sub CopyAnimation()
        
        Dim cloneEffect As Effect
        Dim masterSequence As sequence
        Dim size As Integer
        Dim effects() As Effect
        
        Set masterSequence = ActivePresentation.Slides(1).TimeLine.MainSequence
        size = masterSequence.Count
        ReDim effects(size)
        
        For i = 1 To masterSequence.Count
        
            Set curEffect = ActivePresentation.Slides(1).TimeLine.MainSequence.Item(i)
            Set cloneEffect = ActivePresentation.Slides(1).TimeLine.MainSequence.Clone(curEffect, curEffect.Index)
            'adds clone animation to the first shape on the second slide.
            'ActivePresentation.Slides(2).TimeLine.MainSequence.AddEffect ActivePresentation.Slides(2).Shapes(1), cloneEffect.EffectType
            Set effects(i) = cloneEffect
            cloneEffect.Delete
            
        Next i
    
    End Sub
    

    For more information, click here to refer about Sequence Object (PowerPoint) and here to refer about Effect Object (PowerPoint)

    • Marked as answer by David_JunFeng Tuesday, December 29, 2015 2:48 PM
    Friday, December 18, 2015 8:05 AM

All replies

  • >>>I want to do this using c# coding. I have tried different things but unable to copy the animation from master to slide. Please help

    PowerPoint 2010 and later has new methods to clone animations, you could refer to below VBA code then change them into c#:

    Sub CopyAnimation()
        
        Dim cloneEffect As Effect
        Dim masterSequence As sequence
        Dim size As Integer
        Dim effects() As Effect
        
        Set masterSequence = ActivePresentation.Slides(1).TimeLine.MainSequence
        size = masterSequence.Count
        ReDim effects(size)
        
        For i = 1 To masterSequence.Count
        
            Set curEffect = ActivePresentation.Slides(1).TimeLine.MainSequence.Item(i)
            Set cloneEffect = ActivePresentation.Slides(1).TimeLine.MainSequence.Clone(curEffect, curEffect.Index)
            'adds clone animation to the first shape on the second slide.
            'ActivePresentation.Slides(2).TimeLine.MainSequence.AddEffect ActivePresentation.Slides(2).Shapes(1), cloneEffect.EffectType
            Set effects(i) = cloneEffect
            cloneEffect.Delete
            
        Next i
    
    End Sub
    

    For more information, click here to refer about Sequence Object (PowerPoint) and here to refer about Effect Object (PowerPoint)

    • Marked as answer by David_JunFeng Tuesday, December 29, 2015 2:48 PM
    Friday, December 18, 2015 8:05 AM
  • Hello david,

    I see that you are iterating the masterSequence, but the line ActivePresentation.Slides(1).TimeLine.MainSequence gives me the MainSequence of the current slide and in that look you are just cloning the same slide effecct into the slide again. I do not see the transfer of master Sequence to the Slide. 


    mehulviby

    Friday, December 18, 2015 10:19 AM
  • >>>I do not see the transfer of master Sequence to the Slide.

    According to your description, I suggest that you could use AddEffect Method that returns an Effect object that represents a new animation effect added to a sequence of animation effects.
    You just need uncomment this line code:

    ActivePresentation.Slides(2).TimeLine.MainSequence.AddEffect ActivePresentation.Slides(2).Shapes(1), cloneEffect.EffectType

    Before copy animations:

    then the result:

    Monday, December 21, 2015 8:08 AM