View Single Post
  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default serial numbering

Just to clarify - you put a bookmark named "InvNo" at the place where you
want the number to appear. The next available number is stored in the
settings file. The reset function is only to set either the start number or
to correct the count after making a cock-up!

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Graham Mayor wrote:
OK, a variation on the code on the first link will do that. Put a
bookmark at the place in your document where you want the invoice
number to be printed and run the following macro:

Sub AddNoFromINIFileToBookmark()
Dim SettingsFile As String
Dim Order As String
Dim iCount As String
Dim rInvNo As Range
Dim i As Long

iCount = InputBox("Print how many copies?", _
"Print Copies", 3)
If iCount = "" Then Exit Sub

SettingsFile = Options.DefaultFilePath(wdStartupPath) _
& "\Settings.ini"
Order = System.PrivateProfileString(SettingsFile, _
"InvoiceNumber", "Order")
If Order = "" Then
Order = 1
End If
For i = 1 To iCount
Set rInvNo = ActiveDocument.Bookmarks("InvNo").Range
rInvNo.Text = Format(Order, "00000")
With ActiveDocument
.Bookmarks.Add "InvNo", rInvNo
.Fields.Update
.ActiveWindow.View.ShowFieldCodes = False
.PrintOut
End With
Next
Order = Order + 1
System.PrivateProfileString(SettingsFile, "InvoiceNumber", _
"Order") = Order
End Sub


If you don't want the macro to prompt for the number of copies then
replace
iCount = InputBox("Print how many copies?", _
"Print Copies", 3)
If iCount = "" Then Exit Sub

with

iCount = 3

The next macro will allow you to reset the invoice number to the next
number of choice.

Sub ResetInvoiceNo()
Dim SettingsFile As String
Dim Order As String
Dim sQuery As String
SettingsFile = Options.DefaultFilePath(wdStartupPath) &
"\Settings.ini"
Order = System.PrivateProfileString(SettingsFile, _
"InvoiceNumber", "Order")
sQuery = InputBox("Reset invoice start number?", "Reset", Order)
If sQuery = "" Then Exit Sub
Order = sQuery
System.PrivateProfileString(SettingsFile, "InvoiceNumber", _
"Order") = Order
End Sub

http://www.gmayor.com/installing_macro.htm


grandpappajim wrote:
I intend to print the three parts seperately Graham.

"Graham Mayor" wrote:

Are you printing the three parts separately, or are you using an
impact printer to print all three together?
See http://www.gmayor.com/automatic_numbering_documents.htm and
http://www.gmayor.com/Numbered_labels.htm for some techniques.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



grandpappajim wrote:
I want to print a batch of three part NCR invoices. how do I get
the serial numbers to enter automaticaly?