title: How to pull from Outlook Address book based on values in Excel (VBA)
body: <p>I have the following code that works (I found it on a forum):</p>
  
  <pre><code>Public Sub GetUsers()
  Dim myolApp As Outlook.Application
  Dim myNameSpace As Namespace
  Dim myAddrList As AddressList
  Dim myAddrEntries As addressEntry
  Dim AliasName As String
  Dim i As Integer, r As Integer
  Dim EndRow As Integer, n As Integer
  Dim myStr As String, c As Range
  Dim myPhone As String
  'Dim propertyAccessor As Outlook.propertyAccessor  'This only works with 2007 and may help you out
  
  Set myolApp = CreateObject("Outlook.Application")
  Set myNameSpace = myolApp.GetNamespace("MAPI")
  Set myAddrList = myNameSpace.addressLists("Global Address List")
  
  Dim FullName As String, LastName As String, FirstName As String
  Dim StartRow As Integer
  
  EndRow = Cells(Rows.Count, 3).End(xlUp).Row
  
  StartRow = InputBox("At which row should this start?", "Start Row", 4)
  
  For Each c In Range("A" &amp; StartRow &amp; ":A" &amp; CStr(EndRow))
      AliasName = LCase(Trim(c))
      c = AliasName
      Set myAddrEntries = myAddrList.addressEntries(AliasName)
  
      FullName = myAddrEntries.Name
      FirstName = Trim(Mid(FullName, InStr(FullName, "(") + 1, _
                      InStrRev(FullName, " ") - InStr(FullName, "(")))
      LastName = Right(FullName, Len(FullName) - InStrRev(FullName, " "))
      LastName = Left(LastName, Len(LastName) - 1)
  
      c.Offset(0, 1) = FirstName
      c.Offset(0, 2) = LastName
      c.Offset(0, 3) = FirstName &amp; " " &amp; LastName
  Next c
  End Sub
  </code></pre>
  
  <p>When I provide a single name (first or last) it looks for it in the address book and returns the first and last names of the person it found. </p>
  
  <p>I want to provide the enterprise ID of the person, have it look for that and then return other information (location, phone number etc). </p>
  
  <p>I can't figure out how to do that. First of all, I don't know how outlook knows to search only Alias, as far as I can tell that's only declared in local variables. Also, when I try to pull out other information, for example: </p>
  
  <pre><code>HomeState = myAddrEntries.HomeState
  </code></pre>
  
  <p>I get an error: Object doesn't support this property or method. I don't know what that property would be called - I couldn't find any doc online that showed how properties are named (even when I searched for MAPI docuemntation). </p>
  
  <p>SO, my question is - how can I use this code to search by ID and return other properties such as location, number etc. ALso - how can I generalize that process - is there a list of what those field names are called, is there a way to generate a list?</p>
  
  <p>Thanks!</p>