Cross Reference or VBA Editor to update while printing
So I am able to use this formula
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
to auto number a document that I am doing.
I am making raffle tickets that will be torn apart into two pieces. Top copy as the receipt, bottom portion will be the actual ticket. I have my document set to update on the top and I want it to update on the bottom as well when I print. I have tried to redo the code for the bottom portion or use cross reference and neither option seems to work.
Any idea?
|