Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Powerpoint Quiz Results - Macro Not working

Status
Not open for further replies.

EliseFreedman

Programmer
Dec 6, 2002
470
GB
Hi There

I have created a powerpoint quiz as part of an elearning module. At the end of the result I was trying to create a results slide including the persons name and quiz result.

I am using the following code

I have attached the macro to a button using the hyperlink, mouseclick but when I click the button nothing happens at all. Can anyone suggest what I am doing wrong

The code is as follows

Code:
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: " & 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(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
 
Hi,

Where have you assigned printableSlideNum?

You might consider using ActivePresentation.Slides.Count + 1


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Also, make sure that your code has at the VERY TOP of each module...

[pre]
Option Explicit
[/pre]

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top