none
PowerPoint animated paragraph VSTO RRS feed

  • Question

  • Hi! I am trying to add animation to one selected paragraph in the shape textrange like it does native PowerPoint buttons.

    I set Paragraph property of event object to necessary number and animation appears in animation pane. But it is applied to whole text in the shape.

    Here is my code:

    Effect effect = currentSlide.TimeLine.MainSequence.AddEffect(shape, animation);
    effect.Timing.TriggerType = MsoAnimTriggerType.msoAnimTriggerOnPageClick;
    effect.Timing.Duration = DurationSeconds;
    effect.Exit = triExit;
    effect.Paragraph = 2;

    Is it possible to set animation to only one paragraph in the shape?

    Thank you.

    Tuesday, July 26, 2016 7:21 AM

Answers

  • >>>I set Paragraph property of event object to necessary number and animation appears in animation pane. But it is applied to whole text in the shape.

    According to your description, I have made a sample and reproduce this issue, you could refer to below VBA code workaround:
    Sub DemoBuildEffects()
        Dim intSlideNumber As Integer
        Dim objEffect As Effect
        
        With ActivePresentation.Slides
            intSlideNumber = .count + 1
            'Add new slide with a title and text placeholder
            .Add Index:=intSlideNumber, Layout:=ppLayoutText
            With .Item(intSlideNumber)
                For Each objShape In .Shapes
                    'Identify the title place holder
                    If objShape.PlaceholderFormat.Type = ppPlaceholderTitle Then
                        objShape.TextFrame.TextRange.Text = "Build Effects Demo"
                            
                    'Indentify the text placeholder
                    ElseIf objShape.PlaceholderFormat.Type = _
                        ppPlaceholderBody Then
                        With objShape.TextFrame.TextRange
                            'Insert four paragraphs of text
                            .Text = "This is the first level heading" & _
                                vbCrLf
                            .InsertAfter "This is the second level heading" & _
                                vbCrLf
                            .InsertAfter "This is the third level heading" & _
                                vbCrLf
                            .InsertAfter "This is another first level heading"
        '                    Set indent level of each paragraph
                            .Paragraphs(1, 1).IndentLevel = 1
                            .Paragraphs(2, 1).IndentLevel = 2
                            .Paragraphs(3, 1).IndentLevel = 3
                            .Paragraphs(4, 1).IndentLevel = 1
                        End With
                     With .TimeLine.MainSequence
                        Set efftextfly = .AddEffect _
                            (Shape:=objShape, _
                            effectId:=msoAnimEffectFly, _
                            trigger:=msoAnimTriggerOnPageClick, _
                            Level:=msoAnimateTextByFirstLevel)
                        Debug.Print "Animation Level None"
                        Debug.Print "Effects: " & .count
                     End With
                     
                     Dim num As Integer
                     num = .TimeLine.MainSequence.count
                     
                     For i = num To 2 Step -1
                         .TimeLine.MainSequence.Item(i).Delete
                     Next
                     
                    End If
                Next
            End With
        End With
    End Sub

    In addition you could submit any feedback to PowerPoint UserVoice:

    https://powerpoint.uservoice.com/

    Thanks for your understanding.  
    • Proposed as answer by David_JunFeng Friday, August 5, 2016 8:53 AM
    • Marked as answer by David_JunFeng Friday, August 5, 2016 9:35 AM
    Wednesday, July 27, 2016 5:35 AM

All replies

  • >>>I set Paragraph property of event object to necessary number and animation appears in animation pane. But it is applied to whole text in the shape.

    According to your description, I have made a sample and reproduce this issue, you could refer to below VBA code workaround:
    Sub DemoBuildEffects()
        Dim intSlideNumber As Integer
        Dim objEffect As Effect
        
        With ActivePresentation.Slides
            intSlideNumber = .count + 1
            'Add new slide with a title and text placeholder
            .Add Index:=intSlideNumber, Layout:=ppLayoutText
            With .Item(intSlideNumber)
                For Each objShape In .Shapes
                    'Identify the title place holder
                    If objShape.PlaceholderFormat.Type = ppPlaceholderTitle Then
                        objShape.TextFrame.TextRange.Text = "Build Effects Demo"
                            
                    'Indentify the text placeholder
                    ElseIf objShape.PlaceholderFormat.Type = _
                        ppPlaceholderBody Then
                        With objShape.TextFrame.TextRange
                            'Insert four paragraphs of text
                            .Text = "This is the first level heading" & _
                                vbCrLf
                            .InsertAfter "This is the second level heading" & _
                                vbCrLf
                            .InsertAfter "This is the third level heading" & _
                                vbCrLf
                            .InsertAfter "This is another first level heading"
        '                    Set indent level of each paragraph
                            .Paragraphs(1, 1).IndentLevel = 1
                            .Paragraphs(2, 1).IndentLevel = 2
                            .Paragraphs(3, 1).IndentLevel = 3
                            .Paragraphs(4, 1).IndentLevel = 1
                        End With
                     With .TimeLine.MainSequence
                        Set efftextfly = .AddEffect _
                            (Shape:=objShape, _
                            effectId:=msoAnimEffectFly, _
                            trigger:=msoAnimTriggerOnPageClick, _
                            Level:=msoAnimateTextByFirstLevel)
                        Debug.Print "Animation Level None"
                        Debug.Print "Effects: " & .count
                     End With
                     
                     Dim num As Integer
                     num = .TimeLine.MainSequence.count
                     
                     For i = num To 2 Step -1
                         .TimeLine.MainSequence.Item(i).Delete
                     Next
                     
                    End If
                Next
            End With
        End With
    End Sub

    In addition you could submit any feedback to PowerPoint UserVoice:

    https://powerpoint.uservoice.com/

    Thanks for your understanding.  
    • Proposed as answer by David_JunFeng Friday, August 5, 2016 8:53 AM
    • Marked as answer by David_JunFeng Friday, August 5, 2016 9:35 AM
    Wednesday, July 27, 2016 5:35 AM
  • Thank you for reply.

    I thought about this method. May be we will use it. 

    Wednesday, July 27, 2016 9:49 AM