FAQ

Search:

Mail merge with ActiveBarcodeLink

I want to add a barcode to my mail merge. How can I bind a data field of my control data to ActiveBarcode?
You have to use a macro to print your mail merge. This macro has to make the binding. The following example shows how you can do this. Have a look at the name "Productcode". This is the name of the data field bound to ActiveBarcode in this example. Please replace with your data field name.

Sub MailMerge_example_with_ActiveBarcode()
'
' MailMerge_example_with_ActiveBarcode Makro for Word2000
' (c) 1999 by Frank Horn
'
' 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
To start printing, launch this macro. Otherwise the barcode will not be updated.

There is a example file available in our download section.