How can I increment an invoice number everytime you print

L

Leonardo Da Vinci

Hi all,

I was wondering if someone could help me with the below problem I am having.

I would like to create a template with an invoice number incrementing. I
have the coding to do this via a macro that the invoice number increments
every time you open the template. What I would like to do instead is after
having created a bookmark for the invoice number, that every time I print
the template (for example ... 20 pages), the invoice number increments,
saves to the bookmarked area and to a text file. If I was to open and print
the template again (for example ... another 20 pages) then the invoice
number will continue to increment (I.e. 21, 22, 23 etc) from the previous
time the template was opened.

I am hoping I can have this problem solved as soon as possible. I thank you
in advance for any help you can offer me.
 
G

Graham Mayor

The incrementing number coding that appears on the MVPS web site does not
increment every time you open the template. It increments every time you
create a new document from the template. Re-opening the documents thus
created should be unaffected.
Why would you need to renumber the same invoice? What you need to do is
create a new invoice from the template.

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Greb

Sounds like you want numbered copies.

Try:

Sub NumberCopies()
Dim Message, Title, Default, NumCopies
Message = "Enter the number of copies that you want to
print"
Title = "Print"
Default = "1"
NumCopies = Val(InputBox(Message, Title, Default))
CopyNumber = System.PrivateProfileString
("C:\Settings.Txt", "MacroSettings", "CopyNumber")
If CopyNumber = "" Then
CopyNumber = 1
End If
Dim rng1 As Range, rng2 As Range
Set rng1 = ActiveDocument.Bookmarks("CopyNumber1").Range
Counter = 0
While Counter < NumCopies
rng1.Delete
rng1.Text = CopyNumber
ActiveDocument.PrintOut
CopyNumber = CopyNumber + 1
Counter = Counter + 1
Wend
System.PrivateProfileString
("C:\Settings.txt", "MacroSettings", "CopyNumber") =
CopyNumber
With ActiveDocument.Bookmarks
.Add Name:="CopyNumber1", Range:=rng1
End With
ActiveDocument.Save
End Sub
 

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

Top