Using Powershell to generate Word document containing labels from CSV
In some situations you may have a CSV file containing names and addresses and you wish to print labels on standard Avery 5160 paper. You can manually do a mail merge in Word as outlined here or here. However, if you’re trying to automate the process for a recurring scenario, or in an application, or for a large number of CSV files, this script comes in handy.
This script requires MS Word 2003 or above installed on the computer where it is run. Its input is a comma delimited CSV file containing the following headings:
‘First Name’,’Last Name’,’AddressNo’,’Address’,’City’,’State’,’Zip’
Its output is a Word document containing labels ready to print on standard Avery 5160 labels