'This is just like Example 7-9 except that the buttons on the Printable Slide do 'not show up on the printout. This is most useful if you change the Printable Slide 'to something like a certificate of completion. Dim numCorrect As Integer Dim numIncorrect As Integer Dim userName As String Dim q1Answered As Boolean Dim q2Answered As Boolean Dim q3Answered As Boolean Dim answer1 As String Dim answer2 As String Dim answer3 As String 'The following two Dim statements have been moved out of the PrintablePage 'procedure to allow PrintablePage and PrintResults to use them. Dim homeButton As Shape Dim printButton As Shape Sub GetStarted() Initialize YourName ActivePresentation.SlideShowWindow.View.Next End Sub Sub Initialize() numCorrect = 0 numIncorrect = 0 q1Answered = False q2Answered = False q3Answered = False End Sub Sub YourName() userName = InputBox(Prompt:="Type your name") End Sub Sub DoingWell() MsgBox ("You are doing well, " & userName) End Sub Sub DoingPoorly() MsgBox ("Try to do better next time, " & userName) End Sub Sub Answer1GeorgeWashington() If q1Answered = False Then numCorrect = numCorrect + 1 answer1 = "George Washington" End If q1Answered = True DoingWell ActivePresentation.SlideShowWindow.View.Next End Sub Sub Answer1AbrahamLincoln() If q1Answered = False Then numIncorrect = numIncorrect + 1 answer1 = "Abraham Lincoln" End If q1Answered = True DoingPoorly End Sub Sub Answer2Two() If q2Answered = False Then numCorrect = numCorrect + 1 answer2 = "2" End If q2Answered = True DoingWell ActivePresentation.SlideShowWindow.View.Next End Sub Sub Answer2Four() If q2Answered = False Then numIncorrect = numIncorrect + 1 answer2 = "4" End If q2Answered = True DoingPoorly End Sub Sub Question3() Dim answer 'This is the normal input box stuff answer = InputBox(Prompt:="What is the capital of Maryland?", _ Title:="Question 3") 'If this is the first time they answered, remember this answer 'in answer3 If q3Answered = False Then answer3 = answer End If answer = Trim(answer) answer = LCase(answer) 'Check to see if they got the right answer If answer = "annapolis" Then RightAnswer3 Else WrongAnswer3 End If End Sub Sub RightAnswer3() If q3Answered = False Then numCorrect = numCorrect + 1 End If q3Answered = True DoingWell ActivePresentation.SlideShowWindow.View.Next End Sub Sub WrongAnswer3() If q3Answered = False Then numIncorrect = numIncorrect + 1 End If q3Answered = True DoingPoorly End Sub Sub PrintablePage() Dim printableSlide As Slide 'The following lines are commented out because they have been moved to the top 'of the module. This will allow PrintResults to use them to hide the buttons 'before printing and show them again after printing. 'Dim homeButton As Shape 'Dim printButton As Shape Set printableSlide = ActivePresentation.Slides.Add(Index:=6, _ Layout:=ppLayoutText) printableSlide.Shapes(1).TextFrame.TextRange.Text = _ "Results for " & userName printableSlide.Shapes(2).TextFrame.TextRange.Text = _ "Your Answers" & Chr$(13) & _ "Question 1: " & answer1 & Chr$(13) & _ "Question 2: " & answer2 & Chr$(13) & _ "Question 3: " & answer3 & Chr$(13) & _ "You got " & numCorrect & " out of " & _ numCorrect + numIncorrect & "." & Chr$(13) & _ "Press the Print Results button to print your answers." Set homeButton = ActivePresentation.Slides(6).Shapes.AddShape _ (msoShapeActionButtonCustom, 0, 0, 150, 50) homeButton.TextFrame.TextRange.Text = "Start Again" homeButton.ActionSettings(ppMouseClick).Action = ppActionRunMacro homeButton.ActionSettings(ppMouseClick).Run = "StartAgain" Set printButton = ActivePresentation.Slides(6).Shapes.AddShape _ (msoShapeActionButtonCustom, 200, 0, 150, 50) printButton.TextFrame.TextRange.Text = "Print Results" printButton.ActionSettings(ppMouseClick).Action = ppActionRunMacro printButton.ActionSettings(ppMouseClick).Run = "PrintResults" ActivePresentation.SlideShowWindow.View.Next ActivePresentation.Saved = True End Sub Sub PrintResults() homeButton.Visible = False 'Added to hide button before printing printButton.Visible = False 'Added to hide button before printing ActivePresentation.PrintOptions.OutputType = ppPrintOutputSlides ActivePresentation.PrintOut From:=6, To:=6 homeButton.Visible = True 'Added to show button again after printing printButton.Visible = True 'Added to show button again after printing End Sub Sub StartAgain() ActivePresentation.SlideShowWindow.View.GotoSlide (1) ActivePresentation.Slides(6).Delete ActivePresentation.Saved = True End Sub