Excel vba,从Outlook检索联系人信息,无法检索位置列

问题描述 投票:0回答:1

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

enter image description here

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
excel vba
1个回答
0
投票

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

这里是属性列表,取自Microsoft文档中的the Object Model

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
© www.soinside.com 2019 - 2024. All rights reserved.