I would use a userform instead of a separate from page. Add the userform and add a checkbox for each page and a command button. Here is some code that should work:
Code:
Private Sub CommandButton1_Click()
Dim oCtr As Control
Dim strChecked As String
For Each oCtr In Me.Controls
If TypeName(oCtr) = "CheckBox" Then
If oCtr.Value = True Then
strChecked = strChecked & oCtr.Tag & ","
End If
End If
Next
If strChecked <> vbNullString Then
strChecked = Left(strChecked, Len(strChecked) - 1)
strChecked = fcnConcatenateString(strChecked)
MsgBox strChecked
'ActiveDocument.PrintOut Range = wdPrintRangeOfPages, Pages = strChecked
End If
lbl_Exit:
Exit Sub
End Sub
Private Sub UserForm_Initialize()
Dim oCtr As Control
Dim lngIndex As Long
lngIndex = 1
For Each oCtr In Me.Controls
If TypeName(oCtr) = "CheckBox" Then
oCtr.Caption = "Page " & lngIndex
oCtr.Tag = lngIndex
lngIndex = lngIndex + 1
End If
Next
lbl_Exit:
Exit Sub
End Sub
Function fcnConcatenateString(strRawNumbers As String, Optional strEnd As String)
'Credit Macropod.
Dim arrTemp(), lngIndex_A As Long, lngIndex_B As Integer, lngCounter As Integer
ReDim arrTemp(UBound(Split(strRawNumbers, ",")))
For lngIndex_A = 0 To UBound(Split(strRawNumbers, ","))
arrTemp(lngIndex_A) = Split(strRawNumbers, ",")(lngIndex_A)
Next
For lngIndex_A = 0 To UBound(arrTemp) - 1
If IsNumeric(arrTemp(lngIndex_A)) Then
lngCounter = 2
For lngIndex_B = lngIndex_A + 2 To UBound(arrTemp)
If CInt(arrTemp(lngIndex_A) + lngCounter) <> CInt(arrTemp(lngIndex_B)) Then Exit For
arrTemp(lngIndex_B - 1) = ""
lngCounter = lngCounter + 1
Next
lngIndex_A = lngIndex_B - 2
End If
Next
strRawNumbers = Join(arrTemp, ",")
strRawNumbers = Replace(Replace(Replace(strRawNumbers, ",,", " "), ", ", " "), " ,", " ")
While InStr(strRawNumbers, " ")
strRawNumbers = Replace(strRawNumbers, " ", " ")
Wend
strRawNumbers = Replace(Replace(strRawNumbers, " ", "-"), ",", ", ")
If strEnd <> "" Then
lngIndex_A = InStrRev(strRawNumbers, ",")
If lngIndex_A > 0 Then
strRawNumbers = Left(strRawNumbers, lngIndex_A - 1) & Replace(strRawNumbers, ",", " " & Trim(strEnd), lngIndex_A)
End If
End If
fcnConcatenateString = strRawNumbers
lbl_Exit:
Exit Function
End Function