我无法获取联系人列表的位置信息,它只显示为空白。
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
Location
不是ExchangeUser
对象的属性。您可能在Address
或OfficeLocation
属性之后
这里是属性列表,取自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