Consulting

Results 1 to 3 of 3

Thread: My Code doesn't work

  1. #1
    VBAX Newbie
    Joined
    Dec 2018
    Posts
    2
    Location

    Question My Code doesn't work

    I have the following code that is intended to generate non-repeating random numbers as many as my slides and then go to the random slide after a click. I'd like to add a button to the last slide to end the slide show if possible. This has to be floating because if it is displayed at random, who knows which the last slide is. Anyway, that's secondary but my code seems to work during debug but when I run it, the action button does nothing beginning from the first page. I will appreciate any help. Thanks

    Dim dupSlide As Boolean
    Public curSlide(10) As Integer
    Public numOfSlides As Integer
    Public k As Integer


    Sub flipSlids()
    With ActivePresentation.Slides
    ' If SSW.Presentation.SlideShowSettings.StartingSlide Then
    numOfSlides = .Count
    End With
    Randomize
    For i = 1 To numOfSlides - 1
    100 dupSlide = False
    curSlide(i) = Int(numOfSlides * Rnd) + 1
    If i > 1 Then
    For j = 1 To i - 1
    If curSlide(i) = curSlide(j) Then
    dupSlide = True
    End If
    Next
    End If
    If dupSlide = True Then
    GoTo 100
    ' ActivePresentation.SlideShowWindow.View.GotoSlide (curSlide(i))
    End If
    Next
    k = 1
    ' ActivePresentation.SlideShowWindow.View.GotoSlide (curSlide(k))
    Call shwSlides

    End Sub


    Sub shwSlides()
    If curSlide(k) <> 1 Then
    ActivePresentation.SlideShowWindow.View.GotoSlide (curSlide(k))
    End If
    k = k + 1
    End Sub

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Here an alternative approach for you to consider.

    shuffle.pptm
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Newbie
    Joined
    Dec 2018
    Posts
    2
    Location

    Thumbs up Thanks John

    Quote Originally Posted by John Wilson View Post
    Here an alternative approach for you to consider.

    shuffle.pptm

    This is great John. It works great, and thank you so much. I was a little short sighted. I got frustrated when my code wasn't working and I sought help right away. What I really want to do is have them work in pairs like a question and answer pair and I have to keep track of the pair so that I don't give wrong answers to the questions. I am not sure where to tweak your code to get the desired goal. I you can help me further, it will be so great.
    Thanks a lot.
    tonton

Posting Permissions

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