Shapes appear then disappear then appear again? What's happening?

P

Preschool Mike

This is kind of hard to explain without getting too wordy, but I'll give it a
try. I've created a game - kind of like a maze of hide-n-seek where the
player has to find pictures in a specific order.
First note on the SlideMaster I've created 5 boxes that will hold 5
duplicate copies (with different names) of the pictures that need to be
found. Initially all the pictures are on the SlideMaster in these boxes and
set to visible = False. As they find each picture it appears on the
SlideMaster which can also be seen on all the slides. This is done so the
player knows what they've found.
Playing the game: Initially all the pictures, except the first are set to
visible = False. Once they find the first, clicking on it makes the second
visible (I'm using vba to make them visible because the pictures are on a
different slides) and makes the first visible on the SlideMaster. This
process continues throughout the game (e.g., find the second and it becomes
visible on the SlideMaster and makes the third visible on it's slide and so
on).
My Problem: Example - I find the first picture and click, it appears on the
SlideMaster and then I advance to another slide - now it's gone from the
SlideMaster - however when I advance to yet another slide it reappears. This
is also happening with the pictures the player needs to find during the game,
especially if I don't transverse the maze in the necessary order. I find if
I go through the maze in the correct order to find the pictures everything
works fine except I still encounter the same problem as mentioned with the
pictures on the SlideMaster.

I hope I've explained this clearly. I'm pretty sure my vb is good as it's
not that complicated. Here's a sample:

Sub moneyFarm2Appear()
'Clicking on the wallet runs this procedure. This is the first picture
needed in the game
ActivePresentation.Slides(10).Shapes("moneyFarm2").Visible = True
ActivePresentation.Slides(10).Shapes("moneyFarm").Visible = False
ActivePresentation.SlideMaster.Shapes("walletMaster").Visible = True
End Sub

Sub bananaStore2Appear()
'Clicking on the moneyFarm2 runs this procedure.
ActivePresentation.Slides(12).Shapes("bananaStore2").Visible = True
ActivePresentation.Slides(12).Shapes("bananaStore").Visible = False
ActivePresentation.SlideMaster.Shapes("moneyMaster").Visible = True
End Sub

Sub bucketMountain2Appear()
'Clicking on the bananaStore2 runs this procedure
ActivePresentation.SlideMaster.Shapes("bananaMaster").Visible = True
ActivePresentation.Slides(18).Shapes("bucketMountain").Visible = False
ActivePresentation.Slides(18).Shapes("bucketMountain2").Visible = True
End Sub

Thanks for the help
Mike
 
B

Bill Dilworth

Hi Mike,

You have run into a little known aspect of Masters. When you start the
Master is uniform across all the slides. When you make a change it builds
from a version of the Master and creates a new Master for the slide.

What I would do, if I was building this, is a little more complicated but
simpler.

I would not use the Masters for this, instead I would duplicate the shapes
(with their name labels) on all the slides and run a simple loop to
hide/unhide the shape on all slides. It takes a small fraction of a second
to do, but will not be thrown off by anything.
----
Sub HideMe()
Dim oSld As Slide
Dim oShp As Shape

For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Name = "Whatever" Then oShp.Visible = msoFalse
Next oShp
Next oSld

End Sub
----
This little routine takes moments and hides "Whatever" on all slides
quickly. It may work better for your setup.


This one will work also ...
----
Sub HideMe2()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("Whatever").Visible = msoFalse
Next

On Error GoTo 0
End Sub
 
P

Preschool Mike

Thanks for your help. This is working great for hiding all my shapes, but
not so great for having them reappear. I'm assuming I use the same code to
make them reappear, but just change the name of the procedure to something
like ShowMe and change the property to msoTrue. If I'm wrong then what
should I do.
What's happening for example: I hide all my triangles, ovals, and hearts
upon starting the game - the code works great. I advance to slide 2 click on
a button to have my triangles reappear and it does on slide 2. I advance to
slide 3 and it's not there until I click on the next button to have my ovals
appear. Now on slide 3 I have my triangls and ovals visible, but when I
advance to slide 4 my triangle is visible but not my oval until I click on
the button to have my hearts appear. This happens throughout the
presentation with every shape/picture. Here's the code I've tried to use.

Sub HideMe2()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("triangle").Visible = msoFalse
oSld.Shapes("oval").Visible = msoFalse
oSld.Shapes("heart").Visible = msoFalse
oSld.Shapes("cloud").Visible = msoFalse
Next

On Error GoTo 0
End Sub

Sub ShowTriangle()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("triangle").Visible = msoTrue
Next

On Error GoTo 0
End Sub
Sub ShowOval()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("oval").Visible = msoTrue
Next

On Error GoTo 0
End Sub
Sub ShowHeart()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("heart").Visible = msoTrue
Next

On Error GoTo 0
End Sub

'I've even tried something like this but still get the same results.
Sub ShowAllTriangles()
ActivePresentation.Slides(2).Shapes("triangle").Visible = True
ActivePresentation.Slides(3).Shapes("triangle").Visible = True
ActivePresentation.Slides(4).Shapes("triangle").Visible = True
ActivePresentation.Slides(5).Shapes("triangle").Visible = True
End Sub

Need a little more help.

Thanks,
Mike
 
B

Bill Dilworth

Or even call a hide all and show only one...

-----
Sub HideAll()
Dim oSld As Slide

For Each oSld In ActivePresentation.Slides
oSld.Shapes("Oval").Visible = msoFalse
oSld.Shapes("Rectangle").Visible = msoFalse
oSld.Shapes("Heart").Visible = msoFalse
oSld.Shapes("Cloud").Visible = msoFalse
Next

End Sub


Sub ShowOnlyHearts()
Dim oSld As Slide
On Error Resume Next

HideAll
For Each oSld In ActivePresentation.Slides
oSld.Shapes("Heart").Visible = msoTrue
Next

On Error GoTo 0
End Sub
 
P

Preschool Mike

Getting better, but still the same problem. I've tried everything
recommended. Some work, but not perfect. Some do not. I've put a blank
slide between all my slides. That has helped, but it's not perfect. My
pictures will still hide on some slides and then reappear. Also, sometimes
they don't reappear. I'm starting to wonder if this is because of my game
design and how the player advances from slide to slide. As I said it is kind
of like a maze. From slide one the player can go in 4 directions (this is
just an example, not exact: right - slides 2 - 11, down - slides 12 - 20,
left - slides 21 - 30, and up - slides 31 - 40. The objective is to find the
shapes but in the correct order (lets say the order is star, oval, triangle,
and then heart. So lets say the player chooses to go right where they find
the triangle. Since the triangle is not the first shape in the order they
must go back each slide until they reach slide 1 (this game is also about
remembering where everything is, thus the reason to go back). They've
reached slide 1 and decide to go up where they find the star. They click on
the star and it appears in the box displaying the shapes found and they are
told what shape they have to find next. The inactive oval on slide 10 hides
and the active (the one that runs the macro for the next shape) now appears.
From here they have to go back to slide 1 and hopefully they've remembered
which direction to take to get back to the oval.

So you see it's possible they can go in 3 wrong directions before finally
finding the correct shape. Could this back and forth movement be the cause
of my problem (i.e., revisiting slides previously viewed)?

Here's my code for hiding the shapes. Note I'm not actually using the
shapes mentioned above. This code works well for hiding my shapes. Doesn't
seem to be any problems here.
Sub HideMe2()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("walletMaster").Visible = msoFalse
oSld.Shapes("moneyMaster").Visible = msoFalse
oSld.Shapes("bananaMaster").Visible = msoFalse
oSld.Shapes("bucketMaster").Visible = msoFalse
oSld.Shapes("cupMaster").Visible = msoFalse
oSld.Shapes("eggMaster").Visible = msoFalse
oSld.Shapes("keyMaster").Visible = msoFalse
oSld.Shapes("keyhole2").Visible = msoFalse
oSld.Shapes("moneyFarm2").Visible = msoFalse
oSld.Shapes("bananaStore2").Visible = msoFalse
oSld.Shapes("bucketMountain2").Visible = msoFalse
oSld.Shapes("cupLake2").Visible = msoFalse
oSld.Shapes("eggDesert2").Visible = msoFalse
oSld.Shapes("keyJungle2").Visible = msoFalse
Next

On Error GoTo 0
End Sub

Here's my code for making them reappear along with a couple of explanations
of how things work. This is where I seem to be having problems.

Clicking on the wallet picture runs this procedure.
Sub WaterFall()
Dim oSld As Slide
On Error Resume Next
'Finding the wallet is the first picture they must find.
'When they find and click on it picture moneyFarm hides and
'picture moneyFarm2 becomes visible.
For Each oSld In ActivePresentation.Slides
oSld.Shapes("walletMaster").Visible = msoTrue
oSld.Shapes("moneyFarm2").Visible = msoTrue
oSld.Shapes("moneyFarm").Visible = msoFalse
Next

On Error GoTo 0
End Sub

Picture moneyFarm2 runs this procedure. This is the second picture they
must find.
Sub Farm()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("bananaStore2").Visible = msoTrue
oSld.Shapes("moneyMaster").Visible = msoTrue
oSld.Shapes("bananaStore").Visible = msoFalse
Next

On Error GoTo 0
End Sub
Sub Store()
Dim oSld As Slide
On Error Resume Next

Clicking on the bananaStore2 picture runs this procedure.
For Each oSld In ActivePresentation.Slides
oSld.Shapes("bananaMaster").Visible = msoTrue
oSld.Shapes("bucketMountain2").Visible = msoTrue
oSld.Shapes("bucketMountain").Visible = msoFalse
Next

On Error GoTo 0
End Sub

bucketMountain2 runs this.
Sub Mountain()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("bucketMaster").Visible = msoTrue
oSld.Shapes("cupLake2").Visible = msoTrue
oSld.Shapes("cupLake").Visible = msoFalse
Next

On Error GoTo 0
End Sub
Sub Lake()
Dim oSld As Slide
On Error Resume Next

cupLake2 runs this.
For Each oSld In ActivePresentation.Slides
oSld.Shapes("cupMaster").Visible = msoTrue
oSld.Shapes("eggDesert2").Visible = msoTrue
oSld.Shapes("eggDesert").Visible = msoFalse
Next

On Error GoTo 0
End Sub

eggDesert2 runs this.
Sub Desert()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("eggMaster").Visible = msoTrue
oSld.Shapes("keyJungle2").Visible = msoTrue
oSld.Shapes("keyJungle").Visible = msoFalse
Next

On Error GoTo 0
End Sub

keyJungle2 runs this.
Sub Jungle()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("keyMaster").Visible = msoTrue
oSld.Shapes("keyhole2").Visible = msoTrue
oSld.Shapes("keyhole").Visible = msoFalse
Next

On Error GoTo 0
End Sub

Thanks,

Mike
 
P

Preschool Mike

Preschool Mike said:
Getting better, but still the same problem. I've tried everything
recommended. Some work, but not perfect. Some do not. I've put a blank
slide between all my slides. That has helped, but it's not perfect. My
pictures will still hide on some slides and then reappear. Also, sometimes
they don't reappear. I'm starting to wonder if this is because of my game
design and how the player advances from slide to slide. As I said it is kind
of like a maze. From slide one the player can go in 4 directions (this is
just an example, not exact: right - slides 2 - 11, down - slides 12 - 20,
left - slides 21 - 30, and up - slides 31 - 40. The objective is to find the
shapes but in the correct order (lets say the order is star, oval, triangle,
and then heart. So lets say the player chooses to go right where they find
the triangle. Since the triangle is not the first shape in the order they
must go back each slide until they reach slide 1 (this game is also about
remembering where everything is, thus the reason to go back). They've
reached slide 1 and decide to go up where they find the star. They click on
the star and it appears in the box displaying the shapes found and they are
told what shape they have to find next. The inactive oval on slide 10 hides
and the active (the one that runs the macro for the next shape) now appears.
From here they have to go back to slide 1 and hopefully they've remembered
which direction to take to get back to the oval.

So you see it's possible they can go in 3 wrong directions before finally
finding the correct shape. Could this back and forth movement be the cause
of my problem (i.e., revisiting slides previously viewed)? Note: If I play the game in an order where I only visit each slide once it works perfectly. However, that's not the way it's suppose to be played. Kind of defeats the purpose. Any suggestions?

Here's my code for hiding the shapes. Note I'm not actually using the
shapes mentioned above. This code works well for hiding my shapes. Doesn't
seem to be any problems here.
Sub HideMe2()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("walletMaster").Visible = msoFalse
oSld.Shapes("moneyMaster").Visible = msoFalse
oSld.Shapes("bananaMaster").Visible = msoFalse
oSld.Shapes("bucketMaster").Visible = msoFalse
oSld.Shapes("cupMaster").Visible = msoFalse
oSld.Shapes("eggMaster").Visible = msoFalse
oSld.Shapes("keyMaster").Visible = msoFalse
oSld.Shapes("keyhole2").Visible = msoFalse
oSld.Shapes("moneyFarm2").Visible = msoFalse
oSld.Shapes("bananaStore2").Visible = msoFalse
oSld.Shapes("bucketMountain2").Visible = msoFalse
oSld.Shapes("cupLake2").Visible = msoFalse
oSld.Shapes("eggDesert2").Visible = msoFalse
oSld.Shapes("keyJungle2").Visible = msoFalse
Next

On Error GoTo 0
End Sub

Here's my code for making them reappear along with a couple of explanations
of how things work. This is where I seem to be having problems.

Clicking on the wallet picture runs this procedure.
Sub WaterFall()
Dim oSld As Slide
On Error Resume Next
'Finding the wallet is the first picture they must find.
'When they find and click on it picture moneyFarm hides and
'picture moneyFarm2 becomes visible.
For Each oSld In ActivePresentation.Slides
oSld.Shapes("walletMaster").Visible = msoTrue
oSld.Shapes("moneyFarm2").Visible = msoTrue
oSld.Shapes("moneyFarm").Visible = msoFalse
Next

On Error GoTo 0
End Sub

Picture moneyFarm2 runs this procedure. This is the second picture they
must find.
Sub Farm()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("bananaStore2").Visible = msoTrue
oSld.Shapes("moneyMaster").Visible = msoTrue
oSld.Shapes("bananaStore").Visible = msoFalse
Next

On Error GoTo 0
End Sub
Sub Store()
Dim oSld As Slide
On Error Resume Next

Clicking on the bananaStore2 picture runs this procedure.
For Each oSld In ActivePresentation.Slides
oSld.Shapes("bananaMaster").Visible = msoTrue
oSld.Shapes("bucketMountain2").Visible = msoTrue
oSld.Shapes("bucketMountain").Visible = msoFalse
Next

On Error GoTo 0
End Sub

bucketMountain2 runs this.
Sub Mountain()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("bucketMaster").Visible = msoTrue
oSld.Shapes("cupLake2").Visible = msoTrue
oSld.Shapes("cupLake").Visible = msoFalse
Next

On Error GoTo 0
End Sub
Sub Lake()
Dim oSld As Slide
On Error Resume Next

cupLake2 runs this.
For Each oSld In ActivePresentation.Slides
oSld.Shapes("cupMaster").Visible = msoTrue
oSld.Shapes("eggDesert2").Visible = msoTrue
oSld.Shapes("eggDesert").Visible = msoFalse
Next

On Error GoTo 0
End Sub

eggDesert2 runs this.
Sub Desert()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("eggMaster").Visible = msoTrue
oSld.Shapes("keyJungle2").Visible = msoTrue
oSld.Shapes("keyJungle").Visible = msoFalse
Next

On Error GoTo 0
End Sub

keyJungle2 runs this.
Sub Jungle()
Dim oSld As Slide
On Error Resume Next

For Each oSld In ActivePresentation.Slides
oSld.Shapes("keyMaster").Visible = msoTrue
oSld.Shapes("keyhole2").Visible = msoTrue
oSld.Shapes("keyhole").Visible = msoFalse
Next

On Error GoTo 0
End Sub

Thanks,

Mike
 
P

Preschool Mike

I think you're on to something with the predraw. I tried inserting blank
slides and I'm still having the same issues. As I said my game is kind of
like a maze so there are times when the player must revisit slides previously
viewed. This is where my shapes seem to disappear, upon revisiting slides
previously viewed. They will come back however if I view a slide I've not
viewed yet and even when I revisit a slide for the 3rd time. Is there a way
to make ppt think that it's viewing each slide for the first time?
 

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