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.

Determine which shape was clicked

Visit MVP Shyam Pillai's site for example code that shows you how to determine programmatically which shape was clicked.

Note that you can modify the code to get a reference to the slide the shape is on:

oShp.Parent returns a reference to the slide the shape is on
oShp.Parent.Name returns the name of the slide
oShp.Parent.SlideID returns the SlideID

Here's an example:

Sub ToggleVisibility(oShape As Shape)
    oShape.Visible = Not oShape.Visible
End Sub

Rightclick a shape in PowerPoint, choose Action Settings, Run Macro and pick ToggleVisibility to assign this macro to the shape's Click event.

Then when you run the slide show and click the shape, it'll become invisible.

You could modify the code to make some other shape visible or invisible instead. For example if you have a shape on Slide 1 named "Popup" , assign this macro to its MouseOver Action and it'll appear/disappear as you wave the mouse over it during a screen show:

Sub PopUp(oShape As Shape)

    ActivePresentation.Slides(1).Shapes("Popup").Visible = _
        Not ActivePresentation.Slides(1).Shapes("Popup").Visible

End Sub

But if you use a Mac or need this to work on Macs and PCs

Mac PowerPoint has a few bugs that keep this from working correctly. It doesn't pass an entirely valid shape reference in oShape when you use the examples above. Some properties and methods of oShape work, others throw errors. But you can use the properties that DO work to work around those that don't. Thus:

Sub DoSomethingTo(oSh as Shape)

   Dim oSl as Slide
   Dim oShTemp as Shape

   ' oSh.Parent returns a valid reference to the shape's host slide:  
   Set oSl = ActivePresentation.Slides(oSh.Parent.SlideIndex)

   ' and oSh.Name works:
   MsgBox oSh.Name

   ' So we use those two bits to get a reference 
   ' to the clicked shape like so
   Set oShTemp = oSl.Shapes(oSh.Name)
   With oShTemp
       .TextFrame.TextRange.Text = oSh.Name
       ' and whatever else you want to do with the shape
   End With

End Sub

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


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

Determine which shape was clicked
http://www.pptfaq.com/FAQ00141_Determine_which_shape_was_clicked.htm
Last update 07 June, 2017
Created: