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