PDA

View Full Version : [SOLVED:] VBA Code Help?



DoReMe
04-17-2014, 10:51 AM
I'm making a board game and I have trivia as the chance "cards" (actually slides) on Powerpoint. The first slide shows a question mark and has 3 buttons on the slide for 3 areas of the board people can land on (Yellow, Red, Blue). Teams will be playing on a physical board so I got that covered. So when you land on a yellow spot, you would refer to the Powerpoint and click on the yellow button, and it will take you to the first slide under the yellow section (for example, the yellow section of the slides are slides 2 - 28, the red section is 30-45 etc). There is a button to click back to the first slide where you can re-navigate to another button.

The thing is, I want the slides to be shown in order and not repeat when you click any of the buttons, so when you click yellow the first time, it will show slide 2 -> go back to the first slide -> click yellow again -> shows slide 3, etc up until slide 28, where it'll go to an end slide that basically said you ran out of cards). This concept applies to all the sections (so for red, if you clicked it for the first time, it will show slide 30, then 31, 32, 33 etc). Of course different teams may be on different colors, so it would need to remember which slide it left off on in each section. I'm not sure how to code this in VBA or if it even requires VBA at all... but it seems like it SHOULD be a looping if function.

I'm not a coder and I would really appreciate any input or help on this I can get!

Thank you all :)

John Wilson
04-17-2014, 11:52 AM
Could be done without code .

Have a stack of (eg yellow) shapes. The top shape links to slide 2 and also triggers an exit animation to remove itself. Repeat this for the other shapes in the stack with different links to slides. Haven't tested but it should work.

Witrh code you could increment a tag to indicate the slide to link to


Sub jump_andIncrement(oshp As Shape)
Dim lngJump As Long
'start at slide 2
If oshp.Tags("COUNT") = "" Then oshp.Tags.Add "COUNT", "2"
lngJump = CLng(oshp.Tags("COUNT"))
If lngJump < ActivePresentation.Slides.Count Then
ActivePresentation.SlideShowWindow.View.GotoSlide (lngJump)
'increment
oshp.Tags.Add "COUNT", oshp.Tags("COUNT") + 1
Else
'start again
oshp.Tags.Add "COUNT", "2"
End If
End Sub

DoReMe
04-20-2014, 05:21 PM
Could be done without code .

Have a stack of (eg yellow) shapes. The top shape links to slide 2 and also triggers an exit animation to remove itself. Repeat this for the other shapes in the stack with different links to slides. Haven't tested but it should work.

Sorry for the late reply but I did this and it works perfectly! Thank you so much for the suggestion, I really appreciate it :)!!