none
Randomizing position of answers in multiple choice PowerPoint quiz RRS feed

  • Question

  • A simple 10-question quiz uses shapes hyperlinked to macros that will pop up a message box telling the user that they are "Correct" or "Incorrect".

    What is the most elegant way to randomize the shapes on the slide so that they will be in different positions each time the slideshow is run?

    Wednesday, April 9, 2014 12:51 PM

Answers

  • Hi,

    You can use Application.SlideShowNextSlide and Application.SlideShowBegin to detect the slides beginning and changing. Then you can modify the position of shapes by Shape.Left and Shape.Top.

    Here is a sample for your reference:

    Public WithEvents App As Application
    
    Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
    
      
    
    Dim Showpos As Integer
    
    upperbound = 500
    
    lowerbound = 20
    
    leftPosition = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
    
    topPosition = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
    
       Showpos = Wn.View.CurrentShowPosition + 1
    
       
    
       If Showpos > ActivePresentation.Slides.Count Then
    
            Exit Sub
    
       End If
    
       
    
       With ActivePresentation.Slides(Showpos).Shapes(1)
    
       .Left = leftPosition
    
       .Top = topPosition
    
            
    
       End With
    
    End Sub
    

    In addition, links below may be helpful:

    Application Events

    How to: Use Events with the Application Object

    Rnd Function

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 15, 2014 8:10 AM
    Moderator

All replies

  • I ended up getting the TOP values of each of the shapes, storing those values in an array, generating unique random numbers between 1 and 4, and moving the shapes when the slide is advanced.
    Wednesday, April 9, 2014 2:42 PM
  • Hi,

    You can use Application.SlideShowNextSlide and Application.SlideShowBegin to detect the slides beginning and changing. Then you can modify the position of shapes by Shape.Left and Shape.Top.

    Here is a sample for your reference:

    Public WithEvents App As Application
    
    Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
    
      
    
    Dim Showpos As Integer
    
    upperbound = 500
    
    lowerbound = 20
    
    leftPosition = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
    
    topPosition = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
    
       Showpos = Wn.View.CurrentShowPosition + 1
    
       
    
       If Showpos > ActivePresentation.Slides.Count Then
    
            Exit Sub
    
       End If
    
       
    
       With ActivePresentation.Slides(Showpos).Shapes(1)
    
       .Left = leftPosition
    
       .Top = topPosition
    
            
    
       End With
    
    End Sub
    

    In addition, links below may be helpful:

    Application Events

    How to: Use Events with the Application Object

    Rnd Function

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 15, 2014 8:10 AM
    Moderator