D
Dianne Aldridge
I'm trying to run a simple set of 5 quiz slides and display a printable
slide at the end with the score (I will be adding more slides later;
David, if you're reading this, I'm just trying to put together a quick
& dirty show to display all of my quiz questions for retention testing
at the end of my ARP). After each question is answered, I want to
determine whether or not it is the last question slide; if yes, go to
the printable slide, if no, go to the next slide.
I'm having trouble determining what is the best method to use to
determine if it is the last question slide. I will know the exact slide
number, so I tried to use ActivePresentation.Slide.Count, but it does
not work, I'm never taken to the printable page. I think perhaps I
should use the slide number instead of the count, but I'm not sure of
the syntax for the statement; how to I check for slide #6? I downloaded
Microsoft's VBA reference for PowerPoint to see if it would provide
that information, but it's made for real programmers, not scripters
like me.
Here's my code:
Dim StudentName As String
Dim HaveName As Boolean
Dim NCAirplane As Integer
Dim NIAirplane As Integer
Dim printableSlideNum As Long
Sub Start()
NCAirplane = 0 'number correct
NIAirplane = 0 'number incorrect
printableSlideNum = ActivePresentation.Slides.Count + 1
HaveName = False
While Not HaveName
StudentName = InputBox(prompt:="Please type your name in
the space below", Title:="Student Name")
If StudentName = "" Then
HaveName = False
Else
HaveName = True
End If
Wend
ActivePresentation.SlideShowWindow.View.GotoSlide (2)
End Sub
Sub RightAnswerAirplane()
NCAirplane = NCAirplane + 1
If ActivePresentation.Slide.Count = 6 Then
PrintablePage
End If
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub WrongAnswerAirplane()
NIAirplane = NIAirplane + 1
If ActivePresentation.Slide.Count = 6 Then
PrintablePage
End If
ActivePresentation.slideshowindow.View.Next
End Sub
Sub PrintablePage()
' printableSlideNum = ActivePresentation.Slides.Count + 1
Dim printableSlide As Slide
Set printableSlide =
ActivePresentation.Slides.Add(Index:=printableSlideNum, _
Layout:=ppLayoutText)
printableSlide.FollowMasterBackground = msoFalse
printableSlide.Background.Fill.ForeColor.RGB = vbWhite
printableSlide.Shapes(1).TextFrame.TextRange.Text = "Retention
Results for " & StudentName
printableSlide.Shapes(2).TextFrame.TextRange.Text = _
"Airplane Quiz: " & 100 * NCAirplane / (NIAirplane +
NCAirplane) & "%"
ActivePresentation.SlideShowWindow.View.GotoSlide.printableSlideNum
ActivePresentation.Saved = True
End Sub
slide at the end with the score (I will be adding more slides later;
David, if you're reading this, I'm just trying to put together a quick
& dirty show to display all of my quiz questions for retention testing
at the end of my ARP). After each question is answered, I want to
determine whether or not it is the last question slide; if yes, go to
the printable slide, if no, go to the next slide.
I'm having trouble determining what is the best method to use to
determine if it is the last question slide. I will know the exact slide
number, so I tried to use ActivePresentation.Slide.Count, but it does
not work, I'm never taken to the printable page. I think perhaps I
should use the slide number instead of the count, but I'm not sure of
the syntax for the statement; how to I check for slide #6? I downloaded
Microsoft's VBA reference for PowerPoint to see if it would provide
that information, but it's made for real programmers, not scripters
like me.
Here's my code:
Dim StudentName As String
Dim HaveName As Boolean
Dim NCAirplane As Integer
Dim NIAirplane As Integer
Dim printableSlideNum As Long
Sub Start()
NCAirplane = 0 'number correct
NIAirplane = 0 'number incorrect
printableSlideNum = ActivePresentation.Slides.Count + 1
HaveName = False
While Not HaveName
StudentName = InputBox(prompt:="Please type your name in
the space below", Title:="Student Name")
If StudentName = "" Then
HaveName = False
Else
HaveName = True
End If
Wend
ActivePresentation.SlideShowWindow.View.GotoSlide (2)
End Sub
Sub RightAnswerAirplane()
NCAirplane = NCAirplane + 1
If ActivePresentation.Slide.Count = 6 Then
PrintablePage
End If
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub WrongAnswerAirplane()
NIAirplane = NIAirplane + 1
If ActivePresentation.Slide.Count = 6 Then
PrintablePage
End If
ActivePresentation.slideshowindow.View.Next
End Sub
Sub PrintablePage()
' printableSlideNum = ActivePresentation.Slides.Count + 1
Dim printableSlide As Slide
Set printableSlide =
ActivePresentation.Slides.Add(Index:=printableSlideNum, _
Layout:=ppLayoutText)
printableSlide.FollowMasterBackground = msoFalse
printableSlide.Background.Fill.ForeColor.RGB = vbWhite
printableSlide.Shapes(1).TextFrame.TextRange.Text = "Retention
Results for " & StudentName
printableSlide.Shapes(2).TextFrame.TextRange.Text = _
"Airplane Quiz: " & 100 * NCAirplane / (NIAirplane +
NCAirplane) & "%"
ActivePresentation.SlideShowWindow.View.GotoSlide.printableSlideNum
ActivePresentation.Saved = True
End Sub