Powerful PowerPoint for Educators: Using Visual Basic for Applications to Make PowerPoint Interactive


End If theAnswer = Trim(theAnswer)


Download 1.37 Mb.
Pdf ko'rish
bet145/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   141   142   143   144   145   146   147   148   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

End If
theAnswer = Trim(theAnswer)
theAnswer = LCase(theAnswer)
If theAnswer = "annapolis" Then
RightAnswer
Else
WrongAnswer
End If
End Sub
The changes to this pro cedure from the ex ample in Chapter 7 are simply to ac-
count for the fact that
an 
swer
is an ar ray now. Noth ing else has changed.
The final change to our code co mes in the 
PrintablePage
pro ce dure.
You could simply change this pro cedure to use the ar ray (using
an 
swer(1)
,
an 
swer(2)
,
an 
swer(3)
, in stead of
answer1
,
answer2
,
answer3
), but this
would require you to change the pro cedure every time you add a new ques tion.
The pur pose of com plicating our code with arrays was to eliminate any un neces-
sary chang ing of code. Our new
PrintablePage
pro ce dure fol lows:
Sub PrintablePage()
Dim printableSlide As Slide
Dim homeButton As Shape
Dim printButton As Shape
Set printableSlide = _
ActivePresentation.Slides.Add(In 
dex:=printableSlideNum, _
Lay 
out:=ppLayoutText)
printableSlide.Shapes(1).TextFrame.TextRange.Text = _
"Re 
sults for " & userName
printableSlide.Shapes(2).TextFrame.TextRange.Text = _
"Your An 
swers" & Chr$(13)
For i = 1 To numQuestions
printableSlide.Shapes(2).TextFrame.TextRange.Text = _
printableSlide.Shapes(2).TextFrame.TextRange.Text & _
"Ques 
tion " & i & ": " & an 
swer(i) & Chr$(13)
Next i

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   141   142   143   144   145   146   147   148   ...   191




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling