VB Macro for PowerPoint text Animation

Garrod Hutchison 0 Reputation points
2023-07-28T06:49:17.1266667+00:00

I want to create a simple VB Macro in PowerPoint 2018 for Windows that sets the animation of a selected text box to appear by letter at a speed of 0.01 letter per second. Can anyone help with an example

PowerPoint
PowerPoint
A family of Microsoft presentation graphics products that offer tools for creating presentations and adding graphic effects like multimedia objects and special effects with text.
254 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,720 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,121 Reputation points
    2023-07-31T10:53:04.2233333+00:00
    Hello,
    
    Sure, I can provide you with an example VB macro for PowerPoint that sets the animation of a selected text box to appear by letter at a speed of 0.01 letter per second. Please follow these steps:
    
    Open your PowerPoint presentation and press "Alt + F11" to open the Visual Basic for Applications (VBA) editor.
    
    In the VBA editor, click on "Insert" from the menu, then choose "Module" to insert a new module.
    
    In the module window, paste the following VB macro code:
    
    
    Sub AnimateTextByLetter()
        Dim slide As Slide
        Dim shape As Shape
        Dim effect As Effect
    
        ' Check if a shape (text box) is selected
        If Not ActiveWindow.Selection.Type = ppSelectionShapes Then
            MsgBox "Please select a text box (shape) to animate.", vbExclamation, "No Text Box Selected"
            Exit Sub
        End If
    
        ' Get the selected shape
        Set shape = ActiveWindow.Selection.ShapeRange(1)
    
        ' Check if the selected shape is a text box
        If shape.Type <> msoTextBox Then
            MsgBox "Please select a text box (shape) to animate.", vbExclamation, "Invalid Shape Type"
            Exit Sub
        End If
    
        ' Add an Appear animation effect to the shape
        Set slide = shape.Parent
        Set effect = slide.TimeLine.MainSequence.AddEffect(Shape:=shape, effectId:=msoAnimEffectAppear)
    
        ' Set the animation properties
        With effect
            .TextUnitEffect = msoAnimTextUnitEffectByLetter
            .Timing.Duration = 0.01
        End With
    
        ' Play the animation
        slide.TimeLine.MainSequence.Play
    End Sub
    
    
    
    Close the VBA editor by clicking the "X" button or pressing "Alt + Q."
    Now, you can use this macro to animate a selected text box in your PowerPoint presentation:
    
    Select the text box you want to animate.
    
    Press "Alt + F8" to open the "Macro" dialog box.
    
    Select the "AnimateTextByLetter" macro from the list and click "Run."
    
    The selected text box will now have an Appear animation with each letter appearing at a speed of 0.01 letter per second.
    
    Please note that this macro assumes you are using PowerPoint 2018 for Windows. The macro should work for most versions of PowerPoint, but there might be slight variations in the user interface or object model for different versions. Also, be cautious when running macros, especially from unknown sources, as they can potentially harm your presentation or computer. Always make sure to back up your files before using any macros.
    
    I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.
    
    Hope this resolves your Query !!
    
    --If the reply is helpful, please Upvote and Accept it as an answer–