Video: How to add a barcode to an existing mail merge.
🔊 Make sure audio is turned on to follow the instructions. Captions are available in several languages.
Open an exisiting mail merge document or create a new one.
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:
Sub MailMerge_example_with_ActiveBarcode()
' 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
Do
' Fill ActiveBarcode text property now
ActiveDocument.Barcode1.Text = ActiveDocument.MailMerge.DataSource.DataFields("Productcode").Value
' do not prompt for printing...
Options.PrintBackground = True
' print page
ActiveDocument.PrintOut
' recognize old record
lastone = ActiveDocument.MailMerge.DataSource.ActiveRecord
' select next record
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
'count
num = num + 1
' check if there are new ones
Loop While ActiveDocument.MailMerge.DataSource.ActiveRecord <> lastone
' notify user
MsgBox (Str(num) + " pages printed!")
End If
End Sub
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.
Done.
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.