How do I control display of object on ppt slide with VisualBasic?

M

mike wilson

I would like to control the display of objects on a slide.
If an object is clicked on then I would like it to disappear from the slide
when the slide is returned to.
Can you help?
 
D

David M. Marcovitz

Sub DisappearMe(oShp As Shape)
oShp.Visible = False
End Sub

Link this procedure to your shape, and it should disappear right away. It
would take some more sophisticated code to get it to hang around until you
come back to the slide and only disappear then.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
M

mike wilson

David that was a great help. Unfortunately the shape dissappears from the
slide too when in edit mode. The shape dissapears then I have to add it again
after I have run the show. Do you know the extra code I need to get the shape
back in edit mode?
Thanks again.
Mike.
 
D

David M. Marcovitz

The difficulty is figuring out what is going trigger the shape to
reappear. The code is easy (oShp.Visible = True), but when is that going
to happen? There are several possibilities.

Create a procedure that makes all your shapes visible, something like
(typing off the top of my head so it might not work perfectly):

Sub MakeAllVisible()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld in ActivePresentation.Slides
For Each oShp in oSld.Shapes
oShp.Visible = True
Next oShp
Next oSld
End Sub

You could run this procedure at the beginning of the presentation (e.g.,
have a button on the first slide that says "Click here to begin" that
runs this and adds to the end of it
ActivePresentation.SlideShowWindow.View.Next to go to the next slide).

You could run this when you first get to Edit mode to make everything
reappear.

Alternatively, you could make the shapes on a particular slide visible
when you leave the slide by having something like the following attached
to the button that takes you to the next slide (again, off the top of my
head and untested):

Sub MakeThisSlidesShapesVisible()
Dim oShp As Shape
For Each oShp in ActivePresentation.SlideShowWindow.View.Slide.Shapes
oShp.Visible = True
Next oShp
ActivePresentation.SlideShowWindow.View.Next
End Sub

Another alternative would be to name all your shapes (rather these
methods that scroll through all the shapes on a slide or in the whole
slide show) and have a procedure that makes specific shapes visible.

These solutions are likely to require you to be in Kiosk mode to force
users to click on the buttons you want clicked.

--David
--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
M

mike wilson

David,
This is excellent. Thank you. I am in Kiosk mode so that is not a problem. I
did not think to attach the macro to the Start button. I was trying to add
the code to the end of slide show event - with no success.

The project we are working on is a series of quizes. I am just thinking of a
way to slowly reveal a mathematical shape (abit like pieces of a jigsaw) and
then allow the user to guess the shape being revealed. I foresee more
postings on the way.

Thanks again for your help.

Mike.
 
D

David M. Marcovitz

Great. I'm glad my advice was helpful.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top