P
Poludasu
I am having trouble inserting custom barcode with mail merge fileds.
With ActiveDocument.MailMerge
'get the record count of the datasource
With .DataSource
.ActiveRecord = wdLastRecord
x = .ActiveRecord
'set the activerecord back to the first
.ActiveRecord = wdFirstRecord
y = .ActiveRecord
End With
'loop the datasource count and merge one record at a time
For i = 1 To x
.DataSource.FirstRecord = i
.DataSource.LastRecord = i
PCSBarCd.Message = .DataSource.DataFields("Nick").Value & "|" &
..DataSource.DataFields("Last").Value & "|" &
..DataSource.DataFields("Branch").Value & "|" &
..DataSource.DataFields("Branch_Name").Value & "|" &
..DataSource.DataFields("Branch_Phone").Value
.Destination = wdSendToNewDocument
.Execute Pause:=False
Next i
End With
The above code generates a bar code for all the records, but opens up a new
document for each excel record. I would like to mimic the "Merge to a new
document" functionality with barcodes.
Thank you.
With ActiveDocument.MailMerge
'get the record count of the datasource
With .DataSource
.ActiveRecord = wdLastRecord
x = .ActiveRecord
'set the activerecord back to the first
.ActiveRecord = wdFirstRecord
y = .ActiveRecord
End With
'loop the datasource count and merge one record at a time
For i = 1 To x
.DataSource.FirstRecord = i
.DataSource.LastRecord = i
PCSBarCd.Message = .DataSource.DataFields("Nick").Value & "|" &
..DataSource.DataFields("Last").Value & "|" &
..DataSource.DataFields("Branch").Value & "|" &
..DataSource.DataFields("Branch_Name").Value & "|" &
..DataSource.DataFields("Branch_Phone").Value
.Destination = wdSendToNewDocument
.Execute Pause:=False
Next i
End With
The above code generates a bar code for all the records, but opens up a new
document for each excel record. I would like to mimic the "Merge to a new
document" functionality with barcodes.
Thank you.