View Single Post
 
Old 01-18-2018, 03:31 PM
thecastlingking thecastlingking is offline Windows 10 Office 2010 64bit
Novice
 
Join Date: Jan 2018
Posts: 3
thecastlingking is on a distinguished road
Question Word Macros Issues with printing

Code:
Sub MySerial()
    Dim rngSerialLocation As Range
    Dim intSerialNum As Integer
    Dim strSerialNum As String
    Dim docCurrent As Document
    Dim intNumCopies As Integer
    Dim intCount As Integer

    ' set ref to current active doc
    Set docCurrent = Application.ActiveDocument
    ' set ref to the bookmarked serial number
    Set rngSerialLocation = docCurrent.Bookmarks("Serial").Range

    ' get the starting number
    intSerialNum = Val(rngSerialLocation.Text)
    ' get the number of copies required
    intNumCopies = Val(InputBox$("How many Copies?", _
      "Print Serialized", "1"))

    For intCount = 1 To intNumCopies
        ' print the document
        docCurrent.PrintOut Range:=wdPrintAllDocument
        ' increment the serial number
        intSerialNum = intSerialNum + 1
        ' put into formatted version
        strSerialNum = Format(intSerialNum, "00000")
        ' stuff into proper place
        rngSerialLocation.Text = strSerialNum
    Next intCount

    ' reset the bookmark, since the updating procedure
    ' wipes out the old one
    docCurrent.Bookmarks.Add Name:="Serial", _
      Range:=rngSerialLocation
End Sub
Above is the code I'm using. For whatever reason it prints out of order (like the last ten first, then the others) and the first page printed is black and white, even when colour print is selected. Can anyone help me out?

Last edited by macropod; 01-18-2018 at 11:39 PM. Reason: Added code tags & deteled unnecessary text bolding.
Reply With Quote