print receipts with running number without creating many pages?

J

jaysan3

I would like to print 1000 receipts using Word or Excel but dont want to
create that number of pages. Is there any shorter way to do it?
 
J

jaysan3

Something like labels. It is like I want to create a form that has its own
serial number. I dont want to create 100 pages of that same form.

Easiest example is a cheque book. The number increases but the cheque is
still the same.
 
G

Graham Mayor

J

jaysan3

Hmm, I am new to merging. But from examples given, it seem to capture data
from outlook contacts.

It doesnt help much as I am printing receipts - no contact details needed.
Just a running number at the top of the receipt.
 
G

Graham Mayor

If all the receipts contain exactly the same data apart from the
incrementing number then the Excel method shown on the linked page
http://www.gmayor.com/Numbered_labels.htm will do the job. See also
http://www.gmayor.com/automatic_numbering_documents.htm

If you want to avoid mail merge altogether, then you can do so with a macro.
The following is a minor variation on one I posted some time ago

The numbers are stored in a text file "Settings.ini" which is
saved for convenience in the Word Startup folder (though you can use another
path if you prefer. The macro reads the next number from the ini file, types
it in the bookmarked cell then prints the document. The number
is then incremented by one and the process repeated as many times as you
request certificates from the input box. Finally the next number is written
to the ini file for next time.

I have added a macro to reset the number should that be
required.

Sub AddNoFromINIFileToBookmark()
Dim SettingsFile As String
Dim Order As String
Dim iCount As Integer
Dim i As Long
iCount = InputBox("Print how many receipts?", _
"Print Reciepts", 1)
'Save invoice number in the Word startup folder.
SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"
Order = System.PrivateProfileString(SettingsFile, _
"ReceiptNumber", "Order")
If Order = "" Then
Order = 1
End If
For i = 1 To iCount
With Selection
.GoTo What:=wdGoToBookmark, _
name:="RecNo"
.TypeText Text:=Format(Order, "00000")
End With
ActiveDocument.PrintOut
Order = Order + 1
Next
System.PrivateProfileString(SettingsFile, "ReceiptNumber", _
"Order") = Order
End Sub


Sub ResetReceiptNo()
Dim SettingsFile As String
Dim Order As String
Dim sQuery As String
SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"
'SettingsFile = Options.DefaultFilePath(wdWorkgroupTemplatesPath) & _
"\Settings.ini"

Order = System.PrivateProfileString(SettingsFile, _
"ReceiptNumber", "Order")
sQuery = InputBox("Reset Receipt Number?", "Reset", Order)
Order = sQuery
System.PrivateProfileString(SettingsFile, "ReceiptNumber", _
"Order") = Order - 1
End Sub

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

Put a bookmark named "RecNo" on the receipt document where you want the
number to appear and run the macro to print as many incremented receipts as
you require.


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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

jaysan3

Thanks, Graham. I will try it out.

Graham Mayor said:
If all the receipts contain exactly the same data apart from the
incrementing number then the Excel method shown on the linked page
http://www.gmayor.com/Numbered_labels.htm will do the job. See also
http://www.gmayor.com/automatic_numbering_documents.htm

If you want to avoid mail merge altogether, then you can do so with a macro.
The following is a minor variation on one I posted some time ago

The numbers are stored in a text file "Settings.ini" which is
saved for convenience in the Word Startup folder (though you can use another
path if you prefer. The macro reads the next number from the ini file, types
it in the bookmarked cell then prints the document. The number
is then incremented by one and the process repeated as many times as you
request certificates from the input box. Finally the next number is written
to the ini file for next time.

I have added a macro to reset the number should that be
required.

Sub AddNoFromINIFileToBookmark()
Dim SettingsFile As String
Dim Order As String
Dim iCount As Integer
Dim i As Long
iCount = InputBox("Print how many receipts?", _
"Print Reciepts", 1)
'Save invoice number in the Word startup folder.
SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"
Order = System.PrivateProfileString(SettingsFile, _
"ReceiptNumber", "Order")
If Order = "" Then
Order = 1
End If
For i = 1 To iCount
With Selection
.GoTo What:=wdGoToBookmark, _
name:="RecNo"
.TypeText Text:=Format(Order, "00000")
End With
ActiveDocument.PrintOut
Order = Order + 1
Next
System.PrivateProfileString(SettingsFile, "ReceiptNumber", _
"Order") = Order
End Sub


Sub ResetReceiptNo()
Dim SettingsFile As String
Dim Order As String
Dim sQuery As String
SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"
'SettingsFile = Options.DefaultFilePath(wdWorkgroupTemplatesPath) & _
"\Settings.ini"

Order = System.PrivateProfileString(SettingsFile, _
"ReceiptNumber", "Order")
sQuery = InputBox("Reset Receipt Number?", "Reset", Order)
Order = sQuery
System.PrivateProfileString(SettingsFile, "ReceiptNumber", _
"Order") = Order - 1
End Sub

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

Put a bookmark named "RecNo" on the receipt document where you want the
number to appear and run the macro to print as many incremented receipts as
you require.


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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

jaysan3

Thanks, Graham. I tried the macro method. However when I print it, all the
serial numbers will appear one after another. Meaning, at page 2 it will
print 0000100002
and page 3 will appear 00001000020003 and so forth.
How do I avoid that?
 
G

Graham Mayor

That's what comes of answering without checking the code - sorry. Try the
following instead. These versions have been checked ;)

It still needs a bookmark RecNo where the number is to appear, but it will
update the bookmark rather than simply add to it. The second macro sets the
start number to be used.

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

iCount = InputBox("Print how many receipts?", _
"Print Receipts", 1)
If iCount = "" Then Exit Sub

SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"
Order = System.PrivateProfileString(SettingsFile, _
"ReceiptNumber", "Order")
If Order = "" Then
Order = 1
End If
For i = 1 To iCount

Set rRecNo = ActiveDocument.Bookmarks("RecNo").Range
rRecNo.Text = Format(Order, "00000")

ActiveDocument.Bookmarks.Add "RecNo", rRecNo
' ActiveDocument.PrintOut
Order = Order + 1
Next
System.PrivateProfileString(SettingsFile, "ReceiptNumber", _
"Order") = Order
End Sub


Sub ResetReceiptNo()
Dim SettingsFile As String
Dim Order As String
Dim sQuery As String
SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"
'SettingsFile = Options.DefaultFilePath(wdWorkgroupTemplatesPath) & _
"\Settings.ini"

Order = System.PrivateProfileString(SettingsFile, _
"ReceiptNumber", "Order")
sQuery = InputBox("Reset receipt start number?", "Reset", Order)
If sQuery = "" Then Exit Sub
Order = sQuery
System.PrivateProfileString(SettingsFile, "ReceiptNumber", _
"Order") = Order
End Sub

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

My web site www.gmayor.com

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

Graham Mayor

Graham said:
' ActiveDocument.PrintOut

Oops - You had better remove the apostrophe from the start of the line above
(used while testing) or it won't print :blush:)
 
J

jaysan3

Thanks very much, Graham. It works like a charm.

Graham Mayor said:
Oops - You had better remove the apostrophe from the start of the line above
(used while testing) or it won't print :blush:)

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

My web site www.gmayor.com
 
J

jaysan3

Hi Graham,

Need another help. I would like to put the serial number & barcode (which
is basically just a different font). I cannot repeat inserting the same
bookmark. It seems that I cannot use the same bookmark at 2 different
locations.

Is there any other way besides renaming macros?
 
G

Graham Mayor

Are you saying that the barcode is simply the serial number formatted with a
barcode font, and thus a duplicate of the number that the macro creates?
That being the case add a REF field where you want the bar code to appear
with a charformat switch as follows

{REF RecNo \*Charformat}

Use CTRL+F9 for the field brackets {} then format the field with your bar
code font. That should work when the macro updates the field. To facilitate
that, replace the first macro with the revised version below:

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

iCount = InputBox("Print how many receipts?", _
"Print Receipts", 1)
If iCount = "" Then Exit Sub

SettingsFile = Options.DefaultFilePath(wdStartupPath) & "\Settings.ini"
Order = System.PrivateProfileString(SettingsFile, _
"ReceiptNumber", "Order")
If Order = "" Then
Order = 1
End If
For i = 1 To iCount

Set rRecNo = ActiveDocument.Bookmarks("RecNo").Range
rRecNo.Text = Format(Order, "00000")
With ActiveDocument
.Bookmarks.Add "RecNo", rRecNo
.Fields.Update
.ActiveWindow.View.ShowFieldCodes = False
.PrintOut
End With
Order = Order + 1
Next
System.PrivateProfileString(SettingsFile, "ReceiptNumber", _
"Order") = Order
End Sub

If that is not what you are saying, can you clarify how the bar code relates
to your document and its serial number.

I take it you realise that the number of digits in the number is created by
the format switch in the line

rRecNo.Text = Format(Order, "00000")

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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

jaysan3

Many thanks, Graham. The {REF RecNo} was what I was looking for. Just to put
in multiple instances of the serial number. Then I just changed the font
before running the macro.

Thanks again, Graham. You have solved my problem
 

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