Hi,
it is not about just generating an odd random number,
but about avoiding getting the same number again.
One method would be, to create an array form 1 to
the number of pages in your doc and shuffle the
values in the array. That is the more difficult part,
from which I took code posted once by Rick Rothstein.
Here we go:
' -----------------------------------------------------------------
Sub Test863q()
Dim x As Long ' a counter
Dim r As Long ' result from messagebox
Dim pg As Long ' a pagenumber
Dim pa As Long ' pages all
pa = ActiveDocument.BuiltInDocumentProperties("Number of Pages")
ReDim arr(1 To pa)
For x = 1 To pa
arr(x) = x
Next
arr = RandomizeArray(arr)
For x = 1 To pa
r = MsgBox("Give me a card", vbOKCancel)
If r = 1 Then
pg = arr(x)
If pg Mod 2 = 0 Then
pg = pg - 1
ActiveDocument.PrintOut _
Range:=wdPrintFromTo, _
from:=CStr(pg), to:=CStr(pg + 1)
End If
End If
If r = 2 Then Exit Sub
Next
End Sub
' --------------------------------------------------------------------
Function RandomizeArray(ArrayIn As Variant) As Variant
' Rick Rothstein (MVP VP)
Dim x As Long
Dim RandomIndex As Long
Dim TempElement As Variant
Static RanBefore As Boolean
If Not RanBefore Then
RanBefore = True
Randomize
End If
'Stop
If VarType(ArrayIn) >= vbArray Then
For x = UBound(ArrayIn) To LBound(ArrayIn) Step -1
RandomIndex = Int((x - LBound(ArrayIn) + 1) * _
Rnd + LBound(ArrayIn))
TempElement = ArrayIn(RandomIndex)
ArrayIn(RandomIndex) = ArrayIn(x)
ArrayIn(x) = TempElement
Next
Else
'The passed argument was not an array
'Put error handler here, such as . . .
Beep
End If
'For X = 1 To 38
' MsgBox ArrayIn(X)
'Next
RandomizeArray = ArrayIn
End Function
Good luck!