View Single Post
 
Old 07-25-2019, 02:41 PM
gmaxey gmaxey is online now Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

There are lots of examples for pulling data from Excel available from a Google search. As for printing sequentially numbered copies, you could adapt the following to use your Excel value as the starting number:

Code:
  Sub PrintNumberedCopies()
  Dim NumCopies As String
  Dim StartNum As String
  Dim Counter As Long
  Dim oRng As Range
    If MsgBox("The copy number will appear at the insertion point." _
            & " Is the cursor at the correct position?", _
             vbYesNo, "Placement") = vbNo Then End
    If ActiveDocument.Saved = False Then
      If MsgBox("Do you want to save any changes before" & _
                " printing?", vbYesNoCancel, "Save document?") = vbYes Then
        ActiveDocument.Save
      End If
    End If
    StartNum = Val(InputBox("Enter the starting number.", "Starting Number", 1))
    NumCopies = Val(InputBox("Enter the number of copies that" & _
                             " you want to print", "Copies", 1))
    ActiveDocument.Bookmarks.Add Name:="CopyNum", Range:=Selection.Range
    Set oRng = ActiveDocument.Bookmarks("CopyNum").Range
    Counter = 0
    If MsgBox("Are you sure that you want to print " _
              & NumCopies & " numbered " & " copies of this document", _
              vbYesNoCancel, "On your mark, get set ...?") = vbYes Then
      While Counter < NumCopies
        oRng.Delete
        oRng.Text = StartNum
        ActiveDocument.PrintOut
        StartNum = StartNum + 1
        Counter = Counter + 1
      Wend
    End If
  lbl_Exit:
    Exit Sub
  End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote