Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial Number in Word

Status
Not open for further replies.

webrabbit

MIS
Jan 31, 2003
1,059
US
Is there any way to insert a serial number in Word so that each printed copy gets a unique serial number?
 
There are a number of ways of achieving this, with increasing levels of sophistication. There is an example of one of the more simple methods here.
 
It's a whole 11 lines of code (if we ignore declarations). Given your requirement - something that Word cannot actually do natively - it is about as simple as you'll get.
 
That is about as simple as it gets since Word 2000 and later. It was a lot worse in WordBasic in the earlier versions. Almost everything ended up with error 100!

You could always write it in COBOL or whatever language takes your fancy. There is a generic office API which interfaces to most languages as long as they can talk to C libraries.
 
If you need to print just a number of the copy when printing the same document, there is no macro needed. Save an excel file with a header and a column filled with serial numbers (i.e. "ID" in A1, 1 in A2, 2 in A3 etc.). Now you can do a mail merge using excel data as source, can be combined with any text (Copy no <<ID>> of 10). Send the mail merge to the printer, you can choose a range of records to print.

combo
 
>This link may be more to your liking:

Have to say I'm hardly convinced by that solution.

 
The question is unclear. Do you want to print a batch of documents at a single time, or the same document (apart from the serial number) at multiple arbitrary times.

The assumption seems to be the latter, and I can't say I'm impressed with either of the linked methods (although I like the idea of coding in Cobol!!), but unique serial number is non-specific.

A GUID would be guaranteed unique but perhaps a little unwieldy. Leaving that aside you need to remember the previous number and the usual way (unless you want to use an external central database) to do that would be with a document variable - remembered behind the scenes and displayed on the document surface. A more modern, if slightly more awkward, alternative could be custom xml attached to a content control.

Whatever method you choose, there are two potential issues - remembering to save the document after printing (which could be accomplished in the VBA - and all methods need some VBA) and always working on the same document - in other words not taking copies of it.

Tell us - exactly - what you want and we can tell you - exactly - how to do it. But don't expect it to be a single line of code!

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
It looks as though it is more complicated than I would have thought. It probably is not worth doing in the current case. If in the future I decide to print a serial number, I will do it in COBOL, just like the checks.

Thank you all for your input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top