View Single Post
 
Old 04-21-2021, 04:30 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I think it is easier to deal with Content Controls so I would do this with the following code after putting a Content Control titled "CertNumber" in the location you want the number to appear.
Code:
Sub JHA_Print()
  Dim iStart As Integer, iEnd As Integer, i As Integer, aCC As ContentControl, sVal As String
  'On Error GoTo ErrHandler
  Set aCC = ActiveDocument.SelectContentControlsByTitle("CertNumber")(1)
  sVal = aCC.Range.Text
  If Not IsNumeric(sVal) Then
    iStart = 1
  Else
    iStart = CInt(sVal) + 1
  End If
  iEnd = CInt(InputBox("What is the last Certificate to print?", "Print Certificates To", iStart + 1))
  If iStart > iEnd Then Exit Sub
  With ActiveDocument
    For i = iStart To iEnd
      aCC.Range.Text = i
      .PrintOut
    Next
  End With
'ErrHandler:
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote