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

PPTools

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

Merge Excel, CSV or tab-delimited data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

FixLinks prevents broken links when you distribute PowerPoint presentations

Optimizer saves disk space and bandwidth, shrinks your PowerPoint presentations to the right size for email, screenshow or printing

PPT2HTML gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Prep4PDF preserves interactivity in PowerPoint presentations when you convert to PDF

Image Export converts PowerPoint slides to JPG, PNG, GIF, WMF and more

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

Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2009 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.
Español    Deutsch    Français    Português    Italiano    Nederlands    Greek    Japanese    Korean    Chinese

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.htm
Last update 09 September, 2006
Created: