Consulting

Results 1 to 7 of 7

Thread: Animation by Paragraph

  1. #1

    Animation by Paragraph

    Dear all,

    I've been racking my brains for a while now and I have no idea why this simple code doesn't work. Powerpoint Plus 2019.

    I want VBA to apply Fade in to a bullet list in a textbox or placeholder, each line appearing by Paragraph on click anywhere on slide. Code seems fine, but the last line triggers an error: "Compile error: Method or Data member not found".

    Any help appreciated!! Thanks in advance

    Sub ApplyTextAnimation()
    Dim slide As slide
    Dim shape As shape
    Dim effect As effect
    Set slide = ActivePresentation.Slides(1)
    Set shape = slide.Shapes(1)
    Set effect = slide.TimeLine.MainSequence.AddEffect(shape:=shape, effectId:=msoAnimEffectFade, trigger:=msoAnimTriggerOnPageClick)
    effect.TextUnitEffect = msoAnimTextUnitByParagraph
    End Sub
    Last edited by Aussiebear; 09-23-2023 at 04:25 AM. Reason: Added code tags to supplied code

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Welcome to VBAX El_Ingeniero. Someone will be along soon hopefully to answer your query. BTW when supplying code to this forum, please wrap your code with code tags. See the first line in my signature as to how it needs to be done. Thank you.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Quote Originally Posted by El_Ingeniero View Post
    Dear all,

    I've been racking my brains for a while now and I have no idea why this simple code doesn't work. Powerpoint Plus 2019.

    I want VBA to apply Fade in to a bullet list in a textbox or placeholder, each line appearing by Paragraph on click anywhere on slide. Code seems fine, but the last line triggers an error: "Compile error: Method or Data member not found".

    Any help appreciated!! Thanks in advance

    Sub ApplyTextAnimation()
    Dim slide As slide
    Dim shape As shape
    Dim effect As effect
    Set slide = ActivePresentation.Slides(1)
    Set shape = slide.Shapes(1)
    Set effect = slide.TimeLine.MainSequence.AddEffect(shape:=shape, effectId:=msoAnimEffectFade, trigger:=msoAnimTriggerOnPageClick)
    effect.TextUnitEffect = msoAnimTextUnitByParagraph
    End Sub
    Sub ApplyTextAnimation()
    Dim osld As slide
    Dim oshp As shape
    Dim oeff As effect
    Set osld = ActivePresentation.Slides(1)
    Set oshp = osld.Shapes(2)
    Set oeff = osld.TimeLine.MainSequence.AddEffect(shape:=oshp, effectId:=msoAnimEffectFade, Level:=msoAnimateTextByFirstLevel, trigger:=msoAnimTriggerOnPageClick)
    End Sub
    However you mentioned Shapes(1) - if you are trying to animate a Title Placeholder by paragraph it will always fail even if you use the GUI because titles only have one (real) paragraph.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Quote Originally Posted by John Wilson View Post
    Sub ApplyTextAnimation()
    Dim osld As slide
    Dim oshp As shape
    Dim oeff As effect
    Set osld = ActivePresentation.Slides(1)
    Set oshp = osld.Shapes(2)
    Set oeff = osld.TimeLine.MainSequence.AddEffect(shape:=oshp, effectId:=msoAnimEffectFade, Level:=msoAnimateTextByFirstLevel, trigger:=msoAnimTriggerOnPageClick)
    End Sub
    However you mentioned Shapes(1) - if you are trying to animate a Title Placeholder by paragraph it will always fail even if you use the GUI because titles only have one (real) paragraph.
    PS TextUnitEffect is legacy code from pre 2007 versions + it's not a good idea to use Shape /Slide etc for object variables of the same type - it will soon lead to confusion.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    Thanks for the prompt reply & welcome - sorry, I will use tags next time!

  6. #6
    Quote Originally Posted by John Wilson View Post
    PS TextUnitEffect is legacy code from pre 2007 versions + it's not a good idea to use Shape /Slide etc for object variables of the same type - it will soon lead to confusion.
    Thanks for your comments John!

    Argh! So there is no way of achieving what I'm trying to do? It's so basic I would have thought I'd be a piece of cake. Shame PPT doesn't have a macro record tool, what usually do is (after selecting text placeholder)

    Apply Fade In
    Effect Options > Appear by paragraph

    I've tried asking Chat GPT, but its code is worse than mine!

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Of course there's a way to do this . Did you look at the code I posted?
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •