View Single Post
  #5   Report Post  
Posted to microsoft.public.word.docmanagement
John McGhie [MVP - Word and Word Macintosh] John McGhie [MVP - Word and Word Macintosh] is offline
external usenet poster
 
Posts: 506
Default change test questions to reverse order

Hi Doug:

Oi!!! You're hurting my sales :-)

That's very neat... And very eloquent :-)

Cheers

On 27/8/06 4:32 PM, in article , "Doug
Robbins - Word MVP" wrote:

Here is a macro that will put the questions into a different random order
for each student:

Dim i As Integer, j As Integer, k As Integer, Source As Document, Target As
Document, students As Integer

Dim Message, Title, question As Range

Message = "Enter number of students" ' Set prompt.

Title = "Randomizer" ' Set title.

' Display message, title

students = InputBox(Message, Title)



For k = 1 To students

Set Source = Documents.Open("E:\Worddocs\source1.doc")

Set Target = Documents.Add

For i = 100 To 0 Step -1

j = Int((i * Rnd) + 1)

Set question = Source.Paragraphs(j).Range

Target.Range.InsertAfter question

question.Delete

Next i

' Print and Close Document with random list of questions

Target.PrintOut

' Target.SaveAs ("E:\worddocs\student" & k & ".doc")

Target.Close SaveChanges:=wdDoNotSaveChanges

Source.Close SaveChanges:=wdDoNotSaveChanges

Next k


--

Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.

John McGhie
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410