Share via


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 命名空間