serial numbering

  • Thread starter Thread starter grandpappajim
  • Start date Start date
G

grandpappajim

I want to print a batch of three part NCR invoices. how do I get the serial
numbers to enter automaticaly?
 
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

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
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

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Thanks a lot Graham, I haven't had much exsperience with Macros so this is
going to be a bit of a learning curve.....Scary
Regards Jim
 
http://www.gmayor.com/installing_macro.htm explains what to do with the
code.
Add the macro and a button to a custom toolbar to call it, to the invoice
template. Click the button and it will print three similarly numbered copies
then increment the stored number.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Note that the incremented number is only good for the PC that the template
is used on. If you move this function between (say) PC and laptop, you will
need to make use of the reset macro to ensure that the next invoice number
is correct for the changed PC.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top