Document.MailMergeBeforeRecordMerge 事件
在针对合并中的个别记录执行合并时发生。
命名空间: Microsoft.Office.Tools.Word
程序集: Microsoft.Office.Tools.Word.v4.0.Utilities(在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)
Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)
语法
声明
Event MailMergeBeforeRecordMerge As CancelEventHandler
event CancelEventHandler MailMergeBeforeRecordMerge
备注
若要停止当前记录的邮件合并进程,请将所提供的 CancelEventArgs 的 Cancel 参数设置为 true。
示例
下面的代码示例在合并第一个记录之前显示一条消息。 此示例针对的是应用程序级外接程序。
Private Sub DocumentMailMergeBeforeRecordMerge()
Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
AddHandler vstoDoc.MailMergeBeforeRecordMerge, AddressOf ThisDocument_MailMergeBeforeRecordMerge
End Sub
Private Sub ThisDocument_MailMergeBeforeRecordMerge(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
Dim index As Object = 1
System.Windows.Forms.MessageBox.Show(vstoDoc.MailMerge.DataSource.DataFields.Item(index).Value & _
" is now merging.")
End Sub
private void DocumentMailMergeBeforeRecordMerge()
{
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
vstoDoc.MailMergeBeforeRecordMerge += new System.ComponentModel.CancelEventHandler(ThisDocument_MailMergeBeforeRecordMerge);
}
void ThisDocument_MailMergeBeforeRecordMerge(object sender, System.ComponentModel.CancelEventArgs e)
{
object index = 1;
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
System.Windows.Forms.MessageBox.Show(vstoDoc.MailMerge.DataSource.DataFields[index].Value +
" is now merging.");
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。