Use VBA to display a shape for duration of pres

P

Patrick

xHello -- in a PowerPoint 2003 presentation, I am trying to figure out how to
click a shape (say, a circle) to make another shape (a square) display in
slideshow view. I know I can easily do that with animation. However, in this
case I need to make the square appear and then display on all remaining
slides in the presentation. The circle may be clicked, it may not be, so no
way to tell at which point in the presentation the square should appear -- it
just needs to remain once it appears.

Can this be done with animation? If not, any direction on pulling this off
with VBA would be appreciated.

Thanks!
 
D

David Marcovitz

xHello -- in a PowerPoint 2003 presentation, I am trying to figure out how to
click a shape (say, a circle) to make another shape (a square) display in
slideshow view. I know I can easily do that with animation. However, in this
case I need to make the square appear and then display on all remaining
slides in the presentation. The circle may be clicked, it may not be, so no
way to tell at which point in the presentation the square should appear -- it
just needs to remain once it appears.

Can this be done with animation? If not, any direction on pulling this off
with VBA would be appreciated.

Thanks!

I don't think you can do this with animation. You certainly can do it with
VBA. You can either do it by putting the shapes on the slide master or by
putting them on every slide. The main problem with using the slide master is
that the way to access the slide master in VBA keeps changing with each new
version. If you want to do it on every slide, I would put the square on one
slide and name it (e.g., using Example 8.7 on my site). Then, I would copy
the square to every slide where I want it to appear. Let's say the shape is
named My Wonderful Popup. If you put it on every slide, you would need VBA
code something like (untested air code):

Sub ShowSquareEverywhere()
Dim oSld As Slide

For each oSld in ActivePresentation.Slides
oSld.Shapes("My Wonderful Popup").Visible = msoTrue
Next oSld
End Sub

You would probably need a similar procedure to hide the square (just
changing msoTrue to msoFalse). Now, if the square isn't on every slide but
just on select slides, you could either put some error checking in the loop
so it doesn't bomb if it doesn't find the shape on a slide and just goes on
the to the next slide, or you could specify the specific slides:

ActivePresentation.Slides(3).Shapes("My Wonderful Popup").Visible = msoTrue
ActivePresentation.Slides(4).Shapes("My Wonderful Popup").Visible = msoTrue
ActivePresentation.Slides(7).Shapes("My Wonderful Popup").Visible = msoTrue
ActivePresentation.Slides(10).Shapes("My Wonderful Popup").Visible = msoTrue
ActivePresentation.Slides(12).Shapes("My Wonderful Popup").Visible = msoTrue

That's pretty easy with copy and paste.

I'm sure there are about a million other ways to do this (e.g., Steve will
probably tell you to set tags for the slides with the square as you cycle
through).

The biggest issue you are going to have is figuring out when to trigger the
squares to hide again. The advantage of animations is that they reset
themselves when you start the presentation over. With the .Visible property,
that doesn't automatically reset. I usually accomplish this by having a
button on the first slide that does all the resetting (i.e., the same code
as above with msoTrue changed to msoFalse).

--David


--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
P

Patrick

Thanks for the reply david --

I cannot get this to work, unfortunately. The get/setname worked just fine,
however.

Just to quickly test, I created a shape on slide 2 of a presentation and
named this shape "My Wonderful Popup" (just to follow your example). Then on
slide 1 I created another shape, which I will use to click at the start of
the presentation (in slideshow view) to make all of the shapes that I want to
disappear invisible -- sort of get the whole thing ready. I used your example:

Sub ShowSquareEverywhere()
Dim oSld As Slide
For each oSld in ActivePresentation.Slides
oSld.Shapes("My Wonderful Popup").Visible = msoFalse
Next oSld
End Sub

And changed msoTrue to msoFalse. Then I applied an action setting to the
shape on slide 1 to run the macro ShowSquareEverywhere (not an appropriate
name for this example, but that's ok). When I switch to slideshow view and
click the shape on slide 1, nothing happens.

I assume I have done something wrong. Can I impose on your helpfulness one
more time?
 
D

David Marcovitz

The issue is that you don't have a shape named "My Wonderful Popup" on every
slide so when the procedure gets to a slide without it dies with the
wonderful error message of nothing (how helpful:). Your choices are what I
outlined in my previous message: add some error checking (try putting On
Error Resume Next before the For statement) or only hiding and showing the
shape on the slides you want (ActivePresentation.Slides(2).Shapes("My
Wonderful Popup").Visible = msoTrue.

--David

Thanks for the reply david --

I cannot get this to work, unfortunately. The get/setname worked just fine,
however.

Just to quickly test, I created a shape on slide 2 of a presentation and
named this shape "My Wonderful Popup" (just to follow your example). Then on
slide 1 I created another shape, which I will use to click at the start of
the presentation (in slideshow view) to make all of the shapes that I want to
disappear invisible -- sort of get the whole thing ready. I used your example:

Sub ShowSquareEverywhere()
Dim oSld As Slide
For each oSld in ActivePresentation.Slides
oSld.Shapes("My Wonderful Popup").Visible = msoFalse
Next oSld
End Sub

And changed msoTrue to msoFalse. Then I applied an action setting to the
shape on slide 1 to run the macro ShowSquareEverywhere (not an appropriate
name for this example, but that's ok). When I switch to slideshow view and
click the shape on slide 1, nothing happens.

I assume I have done something wrong. Can I impose on your helpfulness one
more time?

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 

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