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.