會在使用者發出將郵件條碼插入至合併列印出版物的指令時發生 (在 Microsoft Publisher 使用者介面 (UI) 中或以程式設計的方式)。
語法
運算式。MailMergeInsertBarcode (Doc,OkToInsert)
expression 代表 Application 物件的變數。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| Doc | 必要 | 文件 | 目前的出版物。 |
| OkToInsert | 必要 | 布林值 | 輸出參數。 True 是表示 如果有需要,可以插入條碼。 |
註解
使用 TextRange.InsertBarcode 方法,將條碼插入合併列印出版物中。
驗證合併列印的地址的協力廠商增益集可以使用 MailMergeInsertBarcode 事件來聆聽的使用者要求該條碼插入的動作。 在此情況下,當增益集收到 MailMergeInsertBarcode 事件觸發的通知時,它會檢查合併列印清單中位址的有效性,如果位址有效,它會嘗試產生條碼。 如果此嘗試成功,增益集應該會針對 OkToInsert 參數傳回 True。 如果嘗試失敗,增益集應該會傳回 False 。
實際的條碼資料會由 MailMergeGenerateBarcode 事件提供給 Publisher。
當使用者選擇 [合併列印] 或 [型錄合併列印] 工作窗格中的 [新增郵遞條碼],或在 Publisher UI 的 [Publisher 工作] 工作窗格中選擇 [新增郵遞條碼] 時,也會觸發 MailMergeInsertBarcode 事件。 使用者選擇這些 UI 命令的其中一個之前,您必須先將 InsertBarcodeVisible 屬性設定為 True,使其可供使用。
如需搭配 Application 物件使用事件的詳細資訊,請參閱 搭配 Application 物件使用事件。
範例
下列 Microsoft Visual Basic for Applications (VBA) 巨集會示範如何處理 MailMergeInsertBarcode 事件。 它會顯示訊息,詢問是否要繼續進行插入條碼。
Private Sub pubApplication_MailMergeInsertBarcode(ByVal Doc As Document, OkToInsert As Boolean)
Dim intResponse As Integer
intResponse = MsgBox("Proceed to insert barcodes?", vbYesNo)
If intResponse = vbYes Then OkToInsert = True
End Sub
您必須將下列程式碼放在模組的 General Declarations 區段中,才會發生此事件。
Public WithEvents pubApplication As Application
然後,您必須執行下列初始化程序。
Public Sub Initialize_pubApplication()
Set pubApplication = Publisher.Application
End Sub
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。