Hi Ulf,
To extend Shyam Pillai's pptQuiz (
http://skp.mvps.org/ppt00031.htm),
you can do the following. After you do this, all of the questions and
answers will be picked up from the slides instead of the code.
Using the code I have given, the questions and answers will need to be
stored in a specific format:
- create a blank slide for each question
- make the slide hidden
- add a text box to the slide (this must be the only thing on the
slide, excluding any items on the master slide)
- in the text box, type a question followed by the 3 possible answers,
using a separate line for each of these
- select the line with the correct answer and make that line bold
Repeat this for each question that you want to use.
Now for the code changes. Edit the VBA and do these things:
1.
So that we can have a flexible number of questions, change this line:
Const NOOFQS = 3
to:
Dim NOOFQS As Integer
2.
In "Sub BeginQuiz()"
replace everything from
ReDim Qs(NOOFQS)
to (and including)
Ans(2) = 1
with this single statement (to call a function that I'll give in a
moment):
GetValues
3.
The Choices array needs to have it's dimensions swapped over so that
we can use "ReDim Preserve" to extend the array, so replace:
.Shapes("Choice1").TextFrame.TextRange.Text = Choices(QNo - 1,
0)
.Shapes("Choice2").TextFrame.TextRange.Text = Choices(QNo - 1,
1)
.Shapes("Choice3").TextFrame.TextRange.Text = Choices(QNo - 1,
2)
With:
.Shapes("Choice1").TextFrame.TextRange.Text = Choices(0, QNo -
1)
.Shapes("Choice2").TextFrame.TextRange.Text = Choices(1, QNo -
1)
.Shapes("Choice3").TextFrame.TextRange.Text = Choices(2, QNo -
1)
and replace:
AnsList = AnsList & Qs(X) & vbTab & " Answer:" & Choices(X,
Ans(X)) & vbCrLf
with:
AnsList = AnsList & Qs(X) & vbTab & " Answer:" & Choices(Ans(X),
X) & vbCrLf
4.
Finally, you will need to add the code to read the questions and
answers from the slides.
If I post the code here, it will get distorted with line breaks, so
instead I've put in in my blog, where you'll be able to copy'n'paste
it:
http://timhards.com/2005/09/29/powerpoint-quiz/
I hope this helps you,
--
Tim Hards
http://timhards.com/
Chief Software Architect
Perspector - 3D Business Graphics for PowerPoint
http://perspector.com/