вземете Manager от Outlook Contacts с помощта на VBA

Имам кода по-долу, който извлича глобалния списък с адреси от Outlook, след което създава масив с името и отдела.

Бих искал да получа мениджъра на потребителите - но не мога да го намеря в списъка със свойства и oUser.GetExchangeUserManager не работи

    Dim appOL As Outlook.Application ' Object
    Dim oGAL As Outlook.AddressEntries ' .NameSpace  Object
    Dim oContact As Outlook.AddressEntry ' Object
    Dim oUser As ExchangeUser ' Object
    Dim arrUsers(1 To 65000, 1 To 4) As String
    Dim UserIndex As Long
    Dim i As Long

    Set appOL = New Outlook.Application ' CreateObject("Outlook.Application")
    Set oGAL = appOL.GetNameSpace("MAPI").AddressLists("Global Address List").AddressEntries

    For i = 1 To oGAL.Count
        Set oContact = oGAL.Item(i)
        If oContact.AddressEntryUserType = 0 Then
            Set oUser = oContact.GetExchangeUser
            If Len(oUser.lastname) > 0 Then
                UserIndex = UserIndex + 1
                arrUsers(UserIndex, 1) = oUser.Name
                arrUsers(UserIndex, 2) = oUser.Department
                arrUsers(UserIndex, 3) = oUser.JobTitle ' Blank
                'arrUsers(UserIndex, 4) = oUser.GetExchangeUserManager  ' ERROR         
            End If
        End If
    Next i

    appOL.Quit

    If UserIndex > 0 Then
        Range("A2").Resize(UserIndex, UBound(arrUsers, 2)).Value = arrUsers
    End If

    Set appOL = Nothing
    Set oGAL = Nothing
    Set oContact = Nothing
    Set oUser = Nothing
    Erase arrUsers

End Sub

някакви мисли как да получа информация за мениджъра?


person Our Man in Bananas    schedule 11.12.2013    source източник


Отговори (1)


Използвайте AddressEntry.Manager - ще върне друг AddressEntry обект, който представлява мениджъра. Бъдете готови да се справите с Nulls.

person Dmitry Streblechenko    schedule 11.12.2013
comment
благодаря, но в моя код по-горе използвам AddressEntry в моята oContact обектна променлива. Когато сложа точка или точка след oContact, за да видя списъка с членове, няма елемент Мениджър в списъка с членове - person Our Man in Bananas; 12.12.2013
comment
AddressEntry.Manager беше изложен още в Outlook 2000 (не съм проверявал предишните версии). Ако свойството е скрито, Intellisense няма да го покаже. Опитайте се да го въведете във вашия код и да го използвате въпреки това. - person Dmitry Streblechenko; 13.12.2013