Document.MailMergeBeforeMerge 事件

在合并任何记录之前于执行合并时发生。

命名空间:  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 MailMergeBeforeMerge As EventHandler
event EventHandler MailMergeBeforeMerge

备注

若要停止邮件合并进程,请将所提供的 CancelEventArgs 的 Cancel 参数设置为 true。

示例

下面的代码示例在运行任何手动邮件合并之前显示一条消息。此示例针对的是应用程序级外接程序。

Private Sub DocumentMailMergeBeforeMerge()
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    AddHandler vstoDoc.MailMergeBeforeMerge, AddressOf ThisDocument_MailMergeBeforeMerge
End Sub

Private Sub ThisDocument_MailMergeBeforeMerge(ByVal sender As Object, ByVal e As EventArgs)
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    System.Windows.Forms.MessageBox.Show("Your mail merge on " & vstoDoc.Name & " is now starting.")
End Sub
private void DocumentMailMergeBeforeMerge()
{
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.MailMergeBeforeMerge += new EventHandler(ThisDocument_MailMergeBeforeMerge);
}

void ThisDocument_MailMergeBeforeMerge(object sender, EventArgs e)
{
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    System.Windows.Forms.MessageBox.Show("Your mail merge on "
        + vstoDoc.Name + " is now starting.");
}

.NET Framework 安全性

请参见

参考

Document 接口

Microsoft.Office.Tools.Word 命名空间