0

我无法获取联系人列表的位置部分,它只是显示为空白。

在此处输入图像描述

Sub GetOutlookAddressBook()
    Dim objOutlook As Outlook.Application, objAddressList As Outlook.AddressList
    Dim oItem As Outlook.AddressEntry, i As Long
    Application.ScreenUpdating = False
    Set objOutlook = CreateObject("Outlook.Application")
    Set objAddressList = objOutlook.Session.AddressLists("Global Address List")
    Sheets("Sheet1").Range("A:C").ClearContents
    i = 2
    For Each oItem In objAddressList.AddressEntries

        If oItem.Address <> "" Then
          Cells(i, "A") = oItem.Name
          Cells(i, "B") = oItem.GetExchangeUser.ALIAS
          Cells(i, "C") = oItem.GetExchangeUser.PrimarySmtpAddress
          Cells(i, "D") = oItem.GetExchangeUser.Department
          Cells(i, "E") = oItem.GetExchangeUser.Location 'cannot get location

            i = i + 1
        End If
    Next
    Application.ScreenUpdating = True
End Sub
4

1 回答 1

1

Location不是ExchangeUser对象的属性。您可能会在AddressOfficeLocation属性之后

这是一个属性列表,取自Microsoft 文档中的对象模型

Address
AddressEntryUserType
Alias
Application
AssistantName
BusinessTelephoneNumber
City
Class
Comments
CompanyName
Department
DisplayType
FirstName
ID
JobTitle
LastName
MobileTelephoneNumber
Name
OfficeLocation
Parent
PostalCode
PrimarySmtpAddress
PropertyAccessor
Session
StateOrProvince
StreetAddress
Type
YomiCompanyName
YomiDepartment
YomiDisplayName
YomiFirstName
YomiLastName
于 2020-01-15T17:02:28.210 回答