Open an exisiting mail merge document or create a new one.
Add the Barcode Object to your mail merge document. Insert the Barcode object into your mail merge document. Place it where you want it in the document and set the Properties of the object, such as barcode type and size.
This will look like the following screenshot, for example. Note the name of the barcode object (highlighted here in yellow). Usually this will be Barcode1.
A macro is required for the mail merge. You can add the following macro. Copy it to the Clipboard and paste it from there into the Visual Basic for Applications editor of Word:
' Macro shows how to print barcodes in a mail merge.
if MsgBox("Do you want to print mail merged documents?", vbYesNo, "Question") = vbYes Then
'counter to zero
num = 0
'first record is number one
ActiveDocument.MailMerge.DataSource.ActiveRecord = 1
' Fill ActiveBarcode text property now
ActiveDocument.Barcode1.Text = ActiveDocument.MailMerge.DataSource.DataFields("Productcode").Value
' do not prompt for printing...
Options.PrintBackground = True
' print page
' recognize old record
lastone = ActiveDocument.MailMerge.DataSource.ActiveRecord
' select next record
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
num = num + 1
' check if there are new ones
Loop While ActiveDocument.MailMerge.DataSource.ActiveRecord <> lastone
' notify user
MsgBox (Str(num) + " pages printed!")
The result looks like this. In the screenshot, you can also see where the macro is inserted.
Now adjust the macro to your mail merger document:
If the name of your barcode object is not Barcode1, change it in the macro (left yellow mark in the screenshot).
Now you change the field name from your data source, which is to be used for the barcode. In this example, "Productcode" is used (right yellow mark in the screenshot). Change the name within the quotation marks.
Save the document and start the macro for a test print.
Tip: Do start the test printout with very few data sets, so that there are not too much misprints in the event of an error or mistake.
If you have placed the macro not in the document itself but, for example, in Normal. dot, the document must not be in design mode when you execute the macro. This will cause an error. Therefore, switch off the design mode before executing the macro.
If you need support or an individual solution for customization to your needs, we can offer support.
As an easy get to we suggest to download and use the demo shown above that already contains everything that you need:
Mail merge DemoZIPfor Word 2007-2019 (ZIP archive)
A Word document with a barcode control is used for serial printing. The barcode is changed during the serial printing accordingly.