
Tips.Net > WordTips Home > Printing > Printing Personalized Copies of a Document
Summary: Do you need to print individualized copies of documents for a series of individuals? This tip describes how to do just that, without using mail merge. Individual names are pulled from a text file and placed in the header of each document as it is printed. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)
Mahmud asked for a way to print personalized copies of a document. He started with a list of names in a regular text file, one per line, and he wanted to print one copy of the current Word document for each of those names. Further, he wanted the person's name placed in the header of the document.
The process to perform such a task is fairly straightforward: open the text file, grab a name, put it in the header, and then print the document. Another name is grabbed, and the process is repeated until there are no more names in the file. The following macro implements such a process:
Sub PutNamesInHeader()
Dim sName As String
Open "c:/names.txt" For Input As #5
Do While Not EOF(5)
' get the name
Line Input #5, sName
ActiveWindow.ActivePane.View.SeekView = _
wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete
Selection.TypeText Text:=sName
ActiveWindow.ActivePane.View.SeekView = _
wdSeekMainDocument
ActiveDocument.PrintOut
Loop
Close #5
ActiveWindow.ActivePane.View.SeekView = _
wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete
ActiveWindow.ActivePane.View.SeekView = _
wdSeekMainDocument
End Sub
The tricky part of the macro is using the .SeekView property to specify which story in the document you want to work with. As implemented here, the .SeekView property is used repeatedly to switch between the header area and the main document. After the loop (grabbing names and printing) is completed, the header area is cleared and the .SeekView is switched back to the main document.
Tip #152 applies to Microsoft Word versions: 97 2000 2002 2003 2007
Save Time! You can have this tip (and several hundred just like it) in the WordTips annual archives. Imagine having over 400 tips available at your fingertips, in each annual volume.
Discover how to use Word's mail merge tool to create your own custom documents in just minutes. Great e-book answers all your questions. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips