参考:Excel vba outlookのExchangeのグローバルアドレス一覧から特定の肩書から名前を検索するマクロ
Excelに”DATA"という名前のテーブルを用意し、マクロを実行すれば、対象のエイリアスとメールアドレスを出力できました。
vba
1Sub GetNameFromOlGlobalAddress()
2
3 Dim ls As ListObject: Set ls = Range("DATA").ListObject
4 If Not ls.DataBodyRange Is Nothing Then ls.DataBodyRange.Delete
5
6 ' Create an Outlook application.
7 Dim oApp As Outlook.Application: Set oApp = CreateObject("Outlook.Application")
8 Dim oNS As Outlook.Namespace: Set oNS = GetNamespace("MAPI")
9
10 Dim colAL As Outlook.AddressLists ' Outlook.AddressLists
11 Dim oAL As Outlook.AddressList ' Outlook.AddressList
12 Dim colAE As Outlook.AddressEntries
13 Dim oAE As Outlook.addressEntry
14 Dim AddressLists As Outlook.AddressLists
15
16 ' Outlook.AddressEntries
17 Dim addressEntry As Object ' Outlook.AddressEntry
18 Dim oExuser As Outlook.ExchangeUser
19 Set AddressLists = oNS.AddressLists
20
21 '確認して変更する
22 Set oAL = oNS.AddressLists.Item("GALの名前") 'GALを絞り込む 'Set oAL = oNS.AddressLists.Item("JPNTOKYO_0001新宿支店")
23 Set colAE = oAL.AddressEntries
24
25 For Each oAE In colAE
26 Set oExuser = oAE.GetExchangeUser
27 If oAE.AddressEntryUserType = olExchangeUserAddressEntry Then
28
29 Set oExuser = oAE.GetExchangeUser
30 If oExuser.OfficeLocation = "hogefuga Head Office" Then
31 With oExuser
32 ls.ListRows.Add.Range.Value = Array(.Alias, .PrimarySmtpAddress, .BusinessTelephoneNumber)
33 End With
34 End If
35 End If
36 Next
37End Sub
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。