Are you definitely only setting Cancel to True for the one record?
Is it only happening on one particular merge or is it happening on every
Is your Event handling code written in VBA or in a .NET language?
Well word is being instantiated, the merge template opened and the
datasource document created from a C# class I wrote. The event handling
code is called through a macro written in VBA in the merge template
document itself. When I set a break point in the
MailMergeBeforeRecordMerge event handler and step through it works and
fires each time, after it hits the line setting Cancel = True the
entire merge is aborted.
I suppose I am only setting Cancel true for one record since it is the
current record context that the event gets called right? I only see one
Cancel parameter in the event handling routine.
Here is the code if that will shed any light:
Private Sub MailMergeApp_MailMergeBeforeRecordMerge(ByVal Doc As
Document, Cancel As Boolean)
Dim mergeDataTable As Table
Dim mergeData As MailMergeDataSource
If EventId <> CInt(Doc.MailMerge.DataSource.DataFields(8).Value)
Then
EventId = CInt(Doc.MailMerge.DataSource.DataFields(8).Value)
Cancel = False
Else
Cancel = True
End If
If ActiveDocument.Tables.Count > 0 Then
Set mergeDataTable = ActiveDocument.Tables(1)
Set mergeData = Doc.MailMerge.DataSource
newrow = mergeDataTable.Rows.Add()
mergeDataTable.Cell(mergeDataTable.Rows.Count,
1).Range.InsertAfter (mergeData.DataFields(9).Value)
mergeDataTable.Cell(mergeDataTable.Rows.Count,
2).Range.InsertAfter (mergeData.DataFields(10).Value)
mergeDataTable.Cell(mergeDataTable.Rows.Count,
3).Range.InsertAfter (mergeData.DataFields(11).Value)
mergeDataTable.Cell(mergeDataTable.Rows.Count,
4).Range.InsertAfter (mergeData.DataFields(12).Value)
End If
End Sub