Results 1 to 2 of 2

Thread: Moving typewriter text box up screen

  1. #1

    Moving typewriter text box up screen


    I'm trying to use Powerpoint VBA to get a text box to move smoothly up a screen. The box has an entry animation with the text set to appear by letter (to create a typewriter effect). I then want to click on a command buttom to make the box move smoothly up the screen. The code which does this is below : the text box is called 'TxtPrint'.

    The problem is that when I click the button the text box just disappears. I have tried the same code with other types of shape and it works as intended, so there is a problem with how I am applying it to text boxes.

    I am aware that it is straightforward to do this using animations in 'core' powerpoint. However I want to understand the basics of doing it in VBA so I can apply it to more complex problems. Grateful for any advice which people can offer.



    Private Sub Button_Click()
    Dim objSequence As Sequence
    Dim objTxt1 As Shape
    Dim objEffect1 As Effect
    Dim sld As Slide
    Set sld = ActivePresentation.Slides(3)
    Set objTxt1 = sld.Shapes("TxtPrint")
    Set objSequence = sld.TimeLine.MainSequence
    Set objEffect1 = objSequence.AddEffect(Shape:=objTxt1, EffectID:=msoAnimEffectFloat, trigger:=msoAnimTriggerOnClick)
    objEffect1.EffectType = msoAnimEffectPathUp
    'objEffect1.Exit = msoTrue
    End Sub
    Last edited by Aussiebear; 08-13-2022 at 02:11 PM. Reason: Added code tags to submitted code

  2. #2
    VBAX Master
    Feb 2007
    First the code is fine except that it should be trigger:=msoAnimTriggerOnPageClick
    Second usually best to use a standard shape to trigger vba and the use Insert > Action > Run Macro. You do not need to use command buttons

    Last the main problem.

    When you run vba in show mode on a slide that also has animation - usually the slide will be reset to the start (ie BEFORE the animation that shows the text box. This is probably why it disappears. The answer is sadly do not mix animation and vba. But it is possible to go to a specific lick in the animations which MIGHT work for you = change the number of course

    SlideShowWindows(1).View.GotoClick (1)
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials

Tags for this Thread

Posting Permissions

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