Consulting

Results 1 to 6 of 6

Thread: Random Slide Jump with limit- Help

  1. #1

    Random Slide Jump with limit- Help

    I'm very much a newbie with VBA. I'm a teacher and I'm using a VBA code in a PPT program I've written for a special needs student. I learned how to use this code to jump to a random slide. How can I specify the number of times the random jump happens before the slide show moves to a specific (non randomized) slide?

    Here's the code:
    Sub randjump()
    randomize
    Dim Inum As Integer
    Inum=Int(highest # in range-(lowest # in range -1)*rnd+lowest # in range)
    ActivePresentation.SlideShowWindow.View.GotoSlide(Inum)
    End Sub
    Thanks for the help!

    Rob
    Last edited by Aussiebear; 04-28-2023 at 08:58 PM. Reason: Adjusted the code tags

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    Recognise the code!

    You could use a static variable to count the clicks and then an If ...Else

    Sub randjump()
    Randomize
    Static Iclix As Integer
    Dim Inum As Integer
    Iclix = Iclix + 1
        If Iclix < 5 Then
            Inum = Int((3 * Rnd) + 3)
            ActivePresentation.SlideShowWindow.View.GotoSlide (Inum)'random
        Else: ActivePresentation.SlideShowWindow.View.GotoSlide (6)'slide 6 eg
            Iclix = 0
    End If
    End Sub
    Last edited by Aussiebear; 04-28-2023 at 08:59 PM. Reason: Adjusted the code tags
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    Thank you John. I'll give it a try.

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    I should probably have said "insert your own numbers into the Inum line!"
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    John, I tried it and it worked well.
    Do you know of any way to automatically advance to a specific slide? I'm using PPT '04 on a Mac, and I don't see an option to do this. Maybe there is a code VBA code that will do it?

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    I don't use a mac but on a PC (and I guess a mac) there's a mouseover hyperlink option?

    You can have a shape appear as part of the animation sequence and trigger the hyperlink.

    Problems
    - the arrow has to be showing
    - sometimes you find the need to wiggle the mouse (which is no use)

    I usually make a slide transition to a new slide with the trigger shape (full slide size) appearing with previous in an animation that moves eg "fly in from bottom". This seems to simulate the mouse moving if you see what I mean
    If the shape has a mouseover hyperlink to the chosen slide it should automatically go there.
    -
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •