View Single Post
 
Old 04-20-2021, 11:58 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The textbox you refer to has the index #57 - presumably because it's the 57th shape object you've inserted into the document body. Hence, you'd refer to it as .Shapes(57).

And, yes, you could put it in the header, but then you'd refer to it by its header shape index #. If you're going to do that, you might put some text in the textbox like:
"Copy #: "
(without the quotes) and use the following version of the macro:
Code:
Sub JHA_Print()
Dim iStart As Long, iEnd As Long, i As Long
On Error GoTo ErrHandler
iStart = CInt(InputBox("What is the first Certificate to print?", "Print Certificates From", "1"))
iEnd = CInt(InputBox("What is the last Certificate to print?", "Print Certificates To", iStart + 1))
If iStart = 0 Or iStart > iEnd Then Exit Sub
With ActiveDocument
  For i = iStart To iEnd
    With .Sections.First.Headers(wdHeaderFooterPrimary)
      .Shapes(.Shapes.Count).TextFrame.TextRange.Words.Last.Text = i
    End With
    .PrintOut
  Next
End With
ErrHandler:
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote