Application.MailMergeDataSourceLoad イベント (Publisher)

差し込み印刷のためにデータ ファイルがロードされたときに発生します。

構文

MailMergeDataSourceLoad (Doc)

expressionApplication オブジェクトを 表す変数。

パラメーター

名前 必須 / オプション データ型 説明
Doc 必須 Document 差し込み印刷のメイン文書を指定します。

注釈

Application オブジェクト イベントにアクセスするには、コード モジュールの [全般宣言] セクションで Application オブジェクト変数を宣言し、その変数をイベントにアクセスする Application オブジェクトと等しく設定します。

Microsoft Publisher Application オブジェクトでイベントを使用する方法については、「 Application オブジェクト でのイベントの使用」を参照してください。

次の使用例は、データ ソースのロード開始時に、データ ソース ファイル名を示すメッセージを表示します。

Private Sub MailMergeApp_MailMergeDataSourceLoad(ByVal Doc As Document) 
 Dim strDSName As String 
 Dim intDSLength As Integer 
 Dim intDSStart As Integer 
 
 'Pull out of the Name property (which includes path and file name) 
 'only the file name using Visual Basic commands Len, InStrRev, and Right 
 intDSLength = Len(ActiveDocument.MailMerge.DataSource.Name) 
 intDSStart = InStrRev(ActiveDocument.MailMerge.DataSource.Name, "\") 
 intDSStart = intDSLength - intDSStart 
 strDSName = Right(ActiveDocument.MailMerge.DataSource.Name, intDSStart) 
 
 'Deliver a message to user when data source is loading 
 MsgBox "Your data source, " & strDSName & ", is now loading." 
End Sub

このイベントを発生させるには、モジュールの General Declarations セクションに次のコードを配置し、次の初期化ルーチンを実行します。

Private WithEvents MailMergeApp As Application 
 
Sub InitializeMailMergeApp() 
 Set MailMergeApp = Publisher.Application 
End Sub

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。