Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

Proud member of

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Use VBA to create popup text

Problem

How can I make explanatory text pop up when I click a shape?

Solution

This code creates a rectangle with text as a popup when you click the shape you've assigned the macro to.
See notes below to learn how to use it:

Sub Popup(osh As Shape)
' Assign the shape's MouseOver or MouseClick Action Setting as
' Run Macro:  Popup
' Use the formatting dialog, Web Text tab to enter your popup text
' On playback, a popup will display the web text then disappear
' when you click the popup again

    Dim oPopup As Shape
    Dim oSl As Slide
    Dim dOffset As Double
    dOffset = 10

    Set oSl = osh.Parent
    ' create a rectangle for the popup
    Set oPopup = oSl.Shapes.AddShape(msoShapeRectangle, _
        osh.Left + dOffset, _
        osh.Top + dOffset, _
        osh.width, _
        osh.height)

    ' set popup shape properties here as needed
    With oPopup
        ' fill
        .Fill.ForeColor.RGB = RGB(255, 255, 200)
        ' text settings
        With .TextFrame
            .WordWrap = msoTrue
            With .TextRange
                ' text color
                .Font.Color.RGB = RGB(0, 0, 0)
                .Text = osh.AlternativeText
            End With
        End With

        ' Set action setting to Delete
        ' which will delete the new shape when the user clicks it
        .ActionSettings(ppMouseClick).Run = "Delete"
    End With

    ActivePresentation.SlideShowWindow.View.GotoSlide (oSl.SlideIndex)

End Sub

Sub Delete(osh As Shape)
    osh.Delete
End Sub

See How do I use VBA code in PowerPoint? to learn how to use this example code.

Search terms:vba,popup,text


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2022 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Use VBA to create popup text
http://www.pptfaq.com/FAQ00691_Use_VBA_to_create_popup_text.htm
Last update 07 June, 2011
Created: