PDA

View Full Version : Solved: Multiple shapes visible



baz
04-04-2010, 10:08 AM
Hi,
I'm still plugging at a self registration PPt for younger children. As it stands, the child clicks a button, and it randomly generates between 1 and 10 apple pictures, they click the corresponding number and it goes to another slide. This part works fine. What I want to do is to hit the same button and it to generate random amounts of other pictures -it's a farmyard scene so things likew pigs, or hens. I've followed similar scripting but keep getting `index into specified collection is out of bounds' messages.
So, it seems that it will accept having 10 pictures randomly displayed, but if I want a choice of more, it won't work.

Any ideas? Sorry if my post isn't too clear.


baz

John Wilson
04-05-2010, 02:14 AM
Post your code to date Baz

baz
04-05-2010, 02:35 AM
Hi John, thanks for having a look. I've not put all of it, the sub `onepig' is repeated for the other numbers. It's probably quite crude, but it works...or doesn't as the case may be
Edit:(whoops, put wrong bit in)
Public Ivalue As Integer ' = how many apples
Sub ClickMe(oshp As shape)
If Val(oshp.TextFrame.TextRange) = Ivalue Then
rightanswer
Else
wronganswer
End If
End Sub
Sub Pigs()


ActivePresentation.Slides(1).shapes("Tryagain").Visible = False
ActivePresentation.Slides(1).shapes("HMpig").Visible = False
ActivePresentation.Slides(1).shapes("Welldone").Visible = False
ActivePresentation.Slides(1).shapes("cover").Visible = True

Ivalue = Int(10 * Rnd + 1)
If Ivalue = 1 Then
onepig
End If
If Ivalue = 2 Then
twopig
End If
If Ivalue = 3 Then
threepig
End If
If Ivalue = 4 Then
fourpig
End If
If Ivalue = 5 Then
fivepig
End If
If Ivalue = 6 Then
sixpig
End If
If Ivalue = 7 Then
sevenpig
End If
If Ivalue = 8 Then
eightpig
End If
If Ivalue = 9 Then
ninepig
End If
If Ivalue = 10 Then
tenpig
End If
End Sub

Sub rightanswer()
ActivePresentation.Slides(3).shapes("Welldone").Visible = True
ActivePresentation.Slides(3).shapes("Tryagain").Visible = False
ActivePresentation.Slides(3).shapes("HMpig").Visible = False
ActivePresentation.Slides(3).shapes("cover").Visible = False

End Sub
Sub wronganswer()
ActivePresentation.Slides(3).shapes("Tryagain").Visible = True
ActivePresentation.Slides(3).shapes("Welldone").Visible = False
ActivePresentation.Slides(3).shapes("HMpig").Visible = True
End Sub
Sub onepig()
ActivePresentation.Slides(3).shapes("HMApples").Visible = True
ActivePresentation.Slides(3).shapes.Range(Array(64)).Visible = True
ActivePresentation.Slides(3).shapes.Range(Array(65, 66, 67, 68, 69, 70, 71, 72, 73)).Visible = False

baz
04-12-2010, 09:31 AM
Hi all,
Thanks to anyone who pondered this one for me -I have eventually sussed it. (I've re written most of the script so it doesn't look as untidy etc.) I re-built the slide with the shapes i wanted as the starting point -naming them as I went -then did the scripting around that. I had done it the other way. I'm not sure if there is a correct way or not, maybe I should have done it this way to begin with...not to worry I got there in the end.

So, thanks again to anyone who had a look and pondered the mess that I'd posted up here

Baz