連絡先フォルダーからエントリを選択するためのダイアログ ボックスを表示する

このトピックでは、 SelectNamesDialog オブジェクトを使用して、Outlook のユーザー インターフェイスの [ 名前の選択] ダイアログ ボックスに似たダイアログ ボックスに連絡先フォルダーのエントリを表示する方法について説明します。

  1. 連絡先フォルダーに対応するアドレス一覧を探します。 SelectNamesDialog オブジェクトは、 AddressList に基づいてダイアログ ボックス内の全体を表示します。 連絡先フォルダーのエントリを表示するには、連絡先フォルダーに対応する AddressList を探します。 現在のセッションに対して定義されているすべてのアドレス一覧を反復処理し、アドレス一覧ごとに AddressList.GetContactsFolder を使用して、対応するフォルダーと連絡先フォルダーを一致させます。

  2. 連絡先フォルダーのアドレス一覧でダイアログ ボックスを初期化します。

  3. SelectNamesDialog.Display を使用してダイアログ ボックスを表示します。 SelectNamesDialog.Display が True の場合、 SelectNamesDialog.Recipients を使用して、選択したエントリにアクセスできます。

Sub ShowContactsInDialog() 
 Dim oDialog As SelectNamesDialog 
 Dim oAL As AddressList 
 Dim oContacts As Folder 
 
 Set oDialog = Application.Session.GetSelectNamesDialog 
 Set oContacts = _ 
 Application.Session.GetDefaultFolder(olFolderContacts) 
 
 'Look for the address list that corresponds with the Contacts folder 
 For Each oAL In Application.Session.AddressLists 
 If oAL.GetContactsFolder = oContacts Then 
 Exit For 
 End If 
 Next 
 With oDialog 
 'Initialize the dialog box with the address list representing the Contacts folder 
 .InitialAddressList = oAL 
 .ShowOnlyInitialAddressList = True 
 If .Display Then 
 'Recipients Resolved 
 'Access Recipients using oDialog.Recipients 
 End If 
 End With 
End Sub

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

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