Document.MailMergeBeforeRecordMerge 事件
當針對合併中的個別記錄執行合併時發生。
命名空間: Microsoft.Office.Tools.Word
組件: 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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。