Peekaboo Text: Use VBA to make text appear and disappear
Problem
You'd like to have text appear or disappear when you mouse over a shape.
The VBA macros below let you toggle the text in any shape on and off when you click or mouse over the shape.
Remember that VBA macros don't work in the free PowerPoint viewers or in web versions of PowerPoint presentations. If you need a non-VBA solution, see Sonia Coleman's Quick Tips (look for Tip #16)
Solution
Add the VBA subroutines below to your presentation (See How do I USE this VBA stuff in PowerPoint? if that sounds mysterious to you)
For each shape whose text you'd like to show/hide, give it a mouseclick or mouseover action setting of Run Macro: Peekaboo
Now start the slide show. When you click or mouse over the shape, the shape's text toggles on and off.
Peek-a-boo!
To reset the shapes so their text is invisible, run the show and trigger the action for each one where the text is visible. Or run the ResetPeekaboos macro below.
Sub Peekaboo(oSh As Shape) ' Hides/makes visible the shape's text With oSh.TextFrame.TextRange ' If it has text ... If Len(.Text) > 0 Then ' Store the text in a tag so we can retrieve it later oSh.Tags.Add "PeekabooText", .Text ' Now blank the text .Text = "" Else .Text = oSh.Tags("PeekabooText") End If End With ' Update: added this line to make it work in PPT 2007 ' Leaving it in should not affect earlier versions of PPT SlideShowWindows(1).View.GotoSlide (oSh.Parent.SlideIndex) End Sub Sub ResetPeekaboos() ' Resets the shapes with peekaboo text to make the text invisible Dim oSh As Shape Dim oSl As Slide For Each oSl In ActivePresentation.Slides For Each oSh In oSl.Shapes If Len(oSh.Tags("PeekabooText")) > 0 Then oSh.TextFrame.TextRange.Text = "" End If Next ' oSh Next ' oSl End Sub Sub UnhidePeekaboos() ' Resets the shapes with peekaboo text to make the text visible Dim oSh As Shape Dim oSl As Slide For Each oSl In ActivePresentation.Slides For Each oSh In oSl.Shapes If Len(oSh.Tags("PeekabooText")) > 0 Then oSh.TextFrame.TextRange.Text = oSh.Tags("PeekabooText") End If Next ' oSh Next ' oSl End Sub Sub HidePeekaboos() ' Resets the shapes with peekaboo text to make the text invisible ' You must have activated the text as peekaboo one time for this to work Dim oSh As Shape Dim oSl As Slide For Each oSl In ActivePresentation.Slides For Each oSh In oSl.Shapes If Len(oSh.Tags("PeekabooText")) > 0 Then oSh.TextFrame.TextRange.Text = "" End If Next ' oSh Next ' oSl End Sub
See How do I use VBA code in PowerPoint? to learn how to use this example code.
Search terms: