Sorry I wasn't more clear. I do appreciate the help and need it once more.
I having some problems and not quit sure why. I've only been working with
VBA for a few months so I'm a novice at best.
What seems to be happening is the WrongAnswer procedure runs no matter if
the answer is correct or incorrect. I think it's because it's not picking up
the last letter I click on while running the quiz, at least it doesn't appear
on the printable page. Here's how I'd like this to work - on the slide the
word "cat" appears in a Shape1. The child then has to click on "c" "a" "t"
which displays in Shape2 and then you proceed to the next question/problem.
That all seems to work, but when I get to the printable page it displays
"ca_" no "t" and tell me I got the question wrong. Here's my code and some
explanations why I did coeded things the way I did.
Dim userName As String
Dim numCorrect As Integer
Dim numIncorrect As Integer
Dim rightUser As String
Dim qAnswered1 As Boolean
Dim answer1 As String
Dim qAnswered2 As Boolean
Dim answer2 As String
Dim qAnswered3 As Boolean
Dim answer3 As String
Dim numQuestions As Long
Dim printableSlideNum As Long
Dim homeButton As Shape
Dim quitButton As Shape
Dim MyRewardButton As Shape
Dim printButton As Shape
Dim TestName As String
Dim count As Long
Sub Question1(oShp As Shape)
Dim myLetter As String
Dim answer
answer =
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox1").TextFrame.TextRange.Text 'TextBox1 is where their answer will be displayed
myLetter = oShp.TextFrame.TextRange.Text
count = count + 1
If count = 1 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox1") _
..TextFrame.TextRange.Characters(1).Text = myLetter 'Choose
to use (.Characters) and put the answer in one shape because I thought
ElseIf count = 2 Then 'it
would be easier to code to determine if the answer was correct or incorrect
and the printable page
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox1") _
..TextFrame.TextRange.Characters(2).Text = myLetter
ElseIf count = 3 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox1") _
..TextFrame.TextRange.Characters(3).Text = myLetter
If q1Answered = False Then
answer1 = answer
End If
If answer =
ActivePresentation.SlideShowWindow.View.Slide.Shapes("DisplayBox1").TextFrame.TextRange.Text Then 'DisplayBox1 shows the word they must spell
RightAnswer1
Else
WrongAnswer1
End If
CleanCount 'If I don't add this it stops counting after 3 and I can't
proceed with the next question - can't enter any more letters
End If
End Sub
Sub RightAnswer1()
If q1Answered = False Then
numCorrect = numCorrect + 1
End If
q1Answered = True
End Sub
Sub WrongAnswer1()
If q1Answered = False Then
numIncorrect = numIncorrect + 1
End If
q1Answered = True
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub Question2(oShp As Shape)
Dim myLetter As String
Dim answer
answer =
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox2").TextFrame.TextRange.Text
myLetter = oShp.TextFrame.TextRange.Text
count = count + 1
If count = 1 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox2") _
..TextFrame.TextRange.Characters(1).Text = myLetter
ElseIf count = 2 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox2") _
..TextFrame.TextRange.Characters(2).Text = myLetter
ElseIf count = 3 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox2") _
..TextFrame.TextRange.Characters(3).Text = myLetter
If q2Answered = False Then
answer2 = answer
End If
If answer =
ActivePresentation.SlideShowWindow.View.Slide.Shapes("DisplayBox2").TextFrame.TextRange.Text Then
RightAnswer2
Else
WrongAnswer2
End If
CleanCount 'If I don't add this it stops counting after 3 and I can't
proceed with the next question - can't enter any more letters
End If
End Sub
Sub RightAnswer2()
If q2Answered = False Then
numCorrect = numCorrect + 1
End If
q2Answered = True
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub WrongAnswer2()
If q2Answered = False Then
numIncorrect = numIncorrect + 1
End If
q2Answered = True
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub Question3(oShp As Shape)
Dim myLetter As String
Dim answer
answer =
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox3").TextFrame.TextRange.Text
myLetter = oShp.TextFrame.TextRange.Text
count = count + 1
If count = 1 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox3") _
..TextFrame.TextRange.Characters(1).Text = myLetter
ElseIf count = 2 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox3") _
..TextFrame.TextRange.Characters(2).Text = myLetter
ElseIf count = 3 Then
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox3") _
..TextFrame.TextRange.Characters(3).Text = myLetter
If q3Answered = False Then
answer3 = answer
End If
If answer =
ActivePresentation.SlideShowWindow.View.Slide.Shapes("DisplayBox3").TextFrame.TextRange.Text Then
RightAnswer3
Else
WrongAnswer3
End If
CleanCount 'If I don't add this it stops counting after 3 and I can't
proceed with the next question - can't enter any more letters
End If
End Sub
Sub RightAnswer3()
If q3Answered = False Then
numCorrect = numCorrect + 1
End If
q3Answered = True
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub WrongAnswer3()
If q3Answered = False Then
numIncorrect = numIncorrect + 1
End If
q3Answered = True
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub CleanCount()
count = 0 'Added this for the reset button on each slide so if they click on
the wrong letter they can start over also because of above explanation
End Sub
Sub Reset() 'Added this for the reset button on each slide so if they click
on the wrong letter they can start over
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox1").TextFrame.TextRange.Text = ""
CleanCount
End Sub
Sub Reset2() 'Added this for the reset button on each slide so if they click
on the wrong letter they can start over
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox2").TextFrame.TextRange.Text = ""
CleanCount
End Sub
Sub Reset3() 'Added this for the reset button on each slide so if they click
on the wrong letter they can start over
ActivePresentation.SlideShowWindow.View.Slide.Shapes("TextBox3").TextFrame.TextRange.Text = ""
CleanCount
End Sub
Sub GetStarted()
Initialize
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub selectUser(nameButton As Shape)
userName = nameButton.TextFrame.TextRange.Text
rightUser = MsgBox("Are you " & userName & "? ", vbYesNo)
If rightUser = vbYes Then
GetStarted
Else
MsgBox ("Sign in again")
End If
End Sub
Sub YourName()
userName = InputBox(prompt:="Type your name") 'Optional sign in by
typing in student name
Initialize
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub CleanTextBoxes() 'Clears all answer boxes at start up
ActivePresentation.Slides(2).Shapes("TextBox1").TextFrame.TextRange.Text = ""
ActivePresentation.Slides(3).Shapes("TextBox2").TextFrame.TextRange.Text = ""
ActivePresentation.Slides(4).Shapes("TextBox3").TextFrame.TextRange.Text = ""
End Sub
Sub Initialize()
Dim i As Long
CleanTextBoxes
TestName =
ActivePresentation.Slides(1).Shapes("TestNameBox").TextFrame.TextRange.Text
numCorrect = 0
numIncorrect = 0
count = 0
q1Answered = False
q2Answered = False
q3Answered = False
printableSlideNum = ActivePresentation.Slides.count + 1
End Sub
Sub SetObjectName()
Dim objectName As String
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.count = 1 Then
objectName = InputBox(prompt:="Type a name for the object")
objectName = Trim(objectName)
If objectName = "" Then
MsgBox ("You did not type anything. " & _
"the name will remain " & _
ActiveWindow.Selection.ShapeRange.Name)
Else
ActiveWindow.Selection.ShapeRange.Name = objectName
End If
Else
MsgBox _
("You can not name more than one shape at a time. " _
& "Select only one shape and try again.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub
Sub SetSlideName()
Dim slideName As String
slideName = InputBox(prompt:="Type a name for the slide")
slideName = Trim(slideName)
If slideName = "" Then
MsgBox ("you did not type anything. " & _
"The name will remain " & _
ActiveWindow.View.Slide.Name)
Else
ActiveWindow.View.Slide.Name = slideName
End If
End Sub
Sub GetSlideName()
MsgBox ActiveWindow.View.Slide.Name
End Sub
Sub GetObjectName()
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.count = 1 Then
MsgBox (ActiveWindow.Selection.ShapeRange.Name)
Else
MsgBox ("You have selected more than one shape.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub
Sub PrintablePage()
Dim printableSlide As Slide
Set printableSlide = _
ActivePresentation.Slides.Add(Index:=printableSlideNum, _
Layout:=ppLayoutText)
printableSlide.Shapes(1).TextFrame.TextRange.Text = _
"Results for " & userName & Chr$(13) & TestName
printableSlide.Shapes(1).TextFrame.TextRange.Font.Size = 32
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)
printableSlide.Shapes(2).TextFrame.TextRange.Text = _
printableSlide.Shapes(2).TextFrame.TextRange.Text & _
"You got " & numCorrect & " out of " & _
numCorrect + numIncorrect & " correct " & "." & Chr$(13)
printableSlide.Shapes(2).TextFrame.TextRange.Font.Size = 9
Set homeButton = _
ActivePresentation.Slides(printableSlideNum).Shapes.AddShape _
(msoShapeActionButtonCustom, 0, 490, 125, 45)
homeButton.Fill.ForeColor.RGB = vbBlack
homeButton.TextFrame.TextRange.Characters(1, 11).Font.Color.RGB = vbWhite
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, 490, 125, 45)
printButton.Fill.ForeColor.RGB = vbBlack
printButton.TextFrame.TextRange.Characters(1, 11).Font.Color.RGB = vbWhite
printButton.TextFrame.TextRange.Text = "Print Results"
printButton.ActionSettings(ppMouseClick).Action = ppActionRunMacro
printButton.ActionSettings(ppMouseClick).Run = "PrintResults"
ActivePresentation.SlideShowWindow.View.Next
ActivePresentation.Saved = True
Set MyRewardButton = _
ActivePresentation.Slides(printableSlideNum).Shapes.AddShape _
(msoShapeActionButtonCustom, 400, 490, 125, 45)
MyRewardButton.Fill.ForeColor.RGB = vbBlack 'displays ribbon at end to
tell how well they did
MyRewardButton.TextFrame.TextRange.Characters(1, 11).Font.Color.RGB =
vbWhite
MyRewardButton.TextFrame.TextRange.Text = "My Reward"
MyRewardButton.ActionSettings(ppMouseClick).Action = ppActionRunMacro
MyRewardButton.ActionSettings(ppMouseClick).Run = "MyReward"
Set quitButton = _
ActivePresentation.Slides(printableSlideNum).Shapes.AddShape _
(msoShapeActionButtonCustom, 590, 490, 125, 45)
quitButton.Fill.ForeColor.RGB = vbBlack
quitButton.TextFrame.TextRange.Characters(1, 4).Font.Color.RGB = vbWhite
quitButton.TextFrame.TextRange.Text = "Quit"
quitButton.ActionSettings(ppMouseClick).Action = ppActionRunMacro
quitButton.ActionSettings(ppMouseClick).Run = "Quit"
End Sub
Sub Quit()
ActivePresentation.Close
End Sub
Sub PrintResults()
homeButton.Visible = False
printButton.Visible = False
MyRewardButton.Visible = False
quitButton.Visible = False
ActivePresentation.PrintOptions.OutputType = ppPrintOutputSlides
ActivePresentation.PrintOut From:=printableSlideNum, To:=printableSlideNum
homeButton.Visible = True
printButton.Visible = True
MyRewardButton.Visible = True
quitButton.Visible = True
End Sub
Sub StartAgain()
ActivePresentation.SlideShowWindow.View.GotoSlide (1)
ActivePresentation.Slides(printableSlideNum).Delete
ActivePresentation.Saved = True
End Sub
Sub Doing1() 'For the ribbon
Dim myReward1 As Shape
Set myReward1 = _
ActivePresentation.SlideShowWindow.View.Slide.Shapes. _
AddShape(Type:=msoShapeCurvedUpRibbon, Left:=400, Top:=175, Width:=300,
Height:=200)
myReward1.Fill.ForeColor.RGB = vbBlue
myReward1.TextFrame.TextRange.Text = "Excellent"
End Sub
Sub Doing2() 'For the ribbon
Dim myReward2 As Shape
Set myReward2 = _
ActivePresentation.SlideShowWindow.View.Slide.Shapes. _
AddShape(Type:=msoShapeCurvedUpRibbon, Left:=400, Top:=175, Width:=300,
Height:=200)
myReward2.Fill.ForeColor.RGB = vbRed
myReward2.TextFrame.TextRange.Text = "Awesome"
End Sub
Sub Doing3() 'For the ribbon
Dim myReward3 As Shape
Set myReward3 = _
ActivePresentation.SlideShowWindow.View.Slide.Shapes. _
AddShape(Type:=msoShapeCurvedUpRibbon, Left:=400, Top:=175, Width:=300,
Height:=200)
myReward3.Fill.ForeColor.RGB = vbYellow
myReward3.TextFrame.TextRange.Text = "Good Job"
myReward3.TextFrame.TextRange.Characters(1, 8).Font.Color.RGB = vbBlack
End Sub
Sub Doing4()
Dim myReward4 As Shape
Set myReward4 = _
ActivePresentation.SlideShowWindow.View.Slide.Shapes. _
AddShape(Type:=msoShapeCurvedUpRibbon, Left:=400, Top:=175, Width:=300,
Height:=200)
myReward4.Fill.ForeColor.RGB = vbWhite
myReward4.TextFrame.TextRange.Text = "Nice Try"
myReward4.TextFrame.TextRange.Characters(1, 8).Font.Color.RGB = vbBlack
End Sub
Sub MyReward() 'For the ribbon
If numCorrect >= 0.95 * (numCorrect + numIncorrect) Then
Doing1
ElseIf numCorrect >= 0.85 * (numCorrect + numIncorrect) Then
Doing2
ElseIf numCorrect >= 0.75 * (numCorrect + numIncorrect) Then
Doing3
Else
Doing4
End If
End Sub