dareeldill
09-27-2016, 10:23 PM
Hello VBA Gods, I come to kneel at your alter and pray for your guidance once more.
Again, I am using Powerpoint 2010, and I have gotten some great help with the below pasted code and it worked wonderfully on my first presentation. However on my second presentation the code doesn't work. Both presentations are basically the same format but with a different subject matter. I can't for the life of me figure out why its not working.
Basically it is a quiz and on the last page is a "RESULTS" Button. The button runs the Macro "PrintablePage" which ultimately should create a next slide and display all the results from the previous questions and then advance to that slide.
However when I run my slide show, even though all of my other macros up to this point performed as desired, this "RESULTS" button is causing me headaches. When I press the button nothing happens. It does not advance at all. When I press ESC to edit my slide, I notice it has created a slide but with no information written on it, just a blank slide.
As I've stated this code is copied and pasted directly from another presentation that I made that is working perfectly.
Any suggestions?
Sub PrintablePage()
Dim printableSlide As Slide
Dim homeButton As Shape
Dim printButton As Shape
Set printableSlide = _
ActivePresentation.Slides.Add(Index:=printableSlideNum, _
Layout:=ppLayoutText)
printableSlide.Shapes(1).TextFrame.TextRange.Text = _
"Results for " & userName
printableSlide.Shapes(2).TextFrame.TextRange.Text = _
"Your Answers" & Chr$(13) & _
"QUESTION 1: Correct Answer is C. Your answer is " & answer01 & Chr$(9) & "QUESTION 2: Correct Answer is B. Your answer is " & answer02 & Chr$(9) & Chr$(9) & "QUESTION 3: Correct Answer is B. Your answer is " & answer03 & Chr$(13) & _
"QUESTION 4: Correct Answer is D. Your answer is " & answer04 & Chr$(9) & "QUESTION 5: Correct Answer is B. Your answer is " & answer05 & Chr$(9) & Chr$(9) & "QUESTION 6: Correct Answer is D. Your answer is " & answer06 & Chr$(13) & _
"QUESTION 7: Correct Answer is A. Your answer is " & answer07 & Chr$(9) & "QUESTION 8: Correct Answer is B. Your answer is " & answer08 & Chr$(9) & Chr$(9) & "QUESTION 9: Correct Answer is C. Your answer is " & answer09 & Chr$(13) & _
"QUESTION 10: Correct Answer is D. Your answer is " & answer10 & Chr$(9) & "QUESTION 11: Correct Answer is C. Your answer is " & answer11 & Chr$(9) & Chr$(9) & "QUESTION 12: Correct Answer is A. Your answer is " & answer12 & Chr$(13) & _
"QUESTION 13: Correct Answer is B. Your answer is " & answer13 & Chr$(9) & "QUESTION 14: Correct Answer is A. Your answer is " & answer14 & Chr$(9) & Chr$(9) & "QUESTION 15: Correct Answer is D. Your answer is " & answer15 & Chr$(13) & _
"QUESTION 16: Correct Answer is B. Your answer is " & answer16 & Chr$(9) & "QUESTION 17: Correct Answer is D. Your answer is " & answer17 & Chr$(9) & Chr$(9) & "QUESTION 18: Correct Answer is B. Your answer is " & answer18 & Chr$(13) & _
"QUESTION 19: Correct Answer is B. Your answer is " & answer19 & Chr$(9) & "QUESTION 20: Correct Answer is C. Your answer is " & answer20 & Chr$(9) & Chr$(9) & "QUESTION 21: Correct Answer is D. Your answer is " & answer21 & Chr$(13) & _
"QUESTION 22: Correct Answer is A. Your answer is " & answer22 & Chr$(9) & "QUESTION 23: Correct Answer is C. Your answer is " & answer23 & Chr$(9) & Chr$(9) & "QUESTION 24: Correct Answer is C. Your answer is " & answer24 & Chr$(13) & _
"QUESTION 25: Correct Answer is C. Your answer is " & answer25 & Chr$(9) & "QUESTION 26: Correct Answer is C. Your answer is " & answer26 & Chr$(9) & Chr$(9) & "QUESTION 27: Correct Answer is A. Your answer is " & answer27 & Chr$(13) & _
"QUESTION 28: Correct Answer is G. Your answer is " & answer28 & Chr$(9) & "QUESTION 29: Correct Answer is D. Your answer is " & answer29 & Chr$(9) & Chr$(9) & "QUESTION 30: Correct Answer is D. Your answer is " & answer30 & Chr$(13) & _
Chr(13) & Chr(13) & "You got " & numCorrect & " out of " & _
numCorrect + numIncorrect & "." & Chr$(13) & Chr$(13) & _
"Press the Print Results button to print your answers. Press Escape to close test, if prompted DO NOT SAVE."
printableSlide.Shapes(2).TextFrame.TextRange.Font.Size = 10
Set homeButton = _
ActivePresentation.Slides(printableSlideNum).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(printableSlideNum).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()
ActivePresentation.PrintOptions.OutputType = ppPrintOutputSlides
ActivePresentation.PrintOut From:=printableSlideNum, _
To:=printableSlideNum
End Sub
Sub StartAgain()
ActivePresentation.SlideShowWindow.View.GotoSlide 1
ActivePresentation.Slides(printableSlideNum).Delete
ActivePresentation.Saved = True
End Sub
Again, I am using Powerpoint 2010, and I have gotten some great help with the below pasted code and it worked wonderfully on my first presentation. However on my second presentation the code doesn't work. Both presentations are basically the same format but with a different subject matter. I can't for the life of me figure out why its not working.
Basically it is a quiz and on the last page is a "RESULTS" Button. The button runs the Macro "PrintablePage" which ultimately should create a next slide and display all the results from the previous questions and then advance to that slide.
However when I run my slide show, even though all of my other macros up to this point performed as desired, this "RESULTS" button is causing me headaches. When I press the button nothing happens. It does not advance at all. When I press ESC to edit my slide, I notice it has created a slide but with no information written on it, just a blank slide.
As I've stated this code is copied and pasted directly from another presentation that I made that is working perfectly.
Any suggestions?
Sub PrintablePage()
Dim printableSlide As Slide
Dim homeButton As Shape
Dim printButton As Shape
Set printableSlide = _
ActivePresentation.Slides.Add(Index:=printableSlideNum, _
Layout:=ppLayoutText)
printableSlide.Shapes(1).TextFrame.TextRange.Text = _
"Results for " & userName
printableSlide.Shapes(2).TextFrame.TextRange.Text = _
"Your Answers" & Chr$(13) & _
"QUESTION 1: Correct Answer is C. Your answer is " & answer01 & Chr$(9) & "QUESTION 2: Correct Answer is B. Your answer is " & answer02 & Chr$(9) & Chr$(9) & "QUESTION 3: Correct Answer is B. Your answer is " & answer03 & Chr$(13) & _
"QUESTION 4: Correct Answer is D. Your answer is " & answer04 & Chr$(9) & "QUESTION 5: Correct Answer is B. Your answer is " & answer05 & Chr$(9) & Chr$(9) & "QUESTION 6: Correct Answer is D. Your answer is " & answer06 & Chr$(13) & _
"QUESTION 7: Correct Answer is A. Your answer is " & answer07 & Chr$(9) & "QUESTION 8: Correct Answer is B. Your answer is " & answer08 & Chr$(9) & Chr$(9) & "QUESTION 9: Correct Answer is C. Your answer is " & answer09 & Chr$(13) & _
"QUESTION 10: Correct Answer is D. Your answer is " & answer10 & Chr$(9) & "QUESTION 11: Correct Answer is C. Your answer is " & answer11 & Chr$(9) & Chr$(9) & "QUESTION 12: Correct Answer is A. Your answer is " & answer12 & Chr$(13) & _
"QUESTION 13: Correct Answer is B. Your answer is " & answer13 & Chr$(9) & "QUESTION 14: Correct Answer is A. Your answer is " & answer14 & Chr$(9) & Chr$(9) & "QUESTION 15: Correct Answer is D. Your answer is " & answer15 & Chr$(13) & _
"QUESTION 16: Correct Answer is B. Your answer is " & answer16 & Chr$(9) & "QUESTION 17: Correct Answer is D. Your answer is " & answer17 & Chr$(9) & Chr$(9) & "QUESTION 18: Correct Answer is B. Your answer is " & answer18 & Chr$(13) & _
"QUESTION 19: Correct Answer is B. Your answer is " & answer19 & Chr$(9) & "QUESTION 20: Correct Answer is C. Your answer is " & answer20 & Chr$(9) & Chr$(9) & "QUESTION 21: Correct Answer is D. Your answer is " & answer21 & Chr$(13) & _
"QUESTION 22: Correct Answer is A. Your answer is " & answer22 & Chr$(9) & "QUESTION 23: Correct Answer is C. Your answer is " & answer23 & Chr$(9) & Chr$(9) & "QUESTION 24: Correct Answer is C. Your answer is " & answer24 & Chr$(13) & _
"QUESTION 25: Correct Answer is C. Your answer is " & answer25 & Chr$(9) & "QUESTION 26: Correct Answer is C. Your answer is " & answer26 & Chr$(9) & Chr$(9) & "QUESTION 27: Correct Answer is A. Your answer is " & answer27 & Chr$(13) & _
"QUESTION 28: Correct Answer is G. Your answer is " & answer28 & Chr$(9) & "QUESTION 29: Correct Answer is D. Your answer is " & answer29 & Chr$(9) & Chr$(9) & "QUESTION 30: Correct Answer is D. Your answer is " & answer30 & Chr$(13) & _
Chr(13) & Chr(13) & "You got " & numCorrect & " out of " & _
numCorrect + numIncorrect & "." & Chr$(13) & Chr$(13) & _
"Press the Print Results button to print your answers. Press Escape to close test, if prompted DO NOT SAVE."
printableSlide.Shapes(2).TextFrame.TextRange.Font.Size = 10
Set homeButton = _
ActivePresentation.Slides(printableSlideNum).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(printableSlideNum).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()
ActivePresentation.PrintOptions.OutputType = ppPrintOutputSlides
ActivePresentation.PrintOut From:=printableSlideNum, _
To:=printableSlideNum
End Sub
Sub StartAgain()
ActivePresentation.SlideShowWindow.View.GotoSlide 1
ActivePresentation.Slides(printableSlideNum).Delete
ActivePresentation.Saved = True
End Sub