title: Cannot access AddressEntries Object from AddressList Object (Outlook VBA)
body: <p>I am trying to access the AddressEntries property of an AddressList inside a VBA script within Excel. The list is a Global Address List containing contacts stored on an Exchange Server. </p>
  
  <p>When I try to run the following code though, it gives me an error:</p>
  
  <blockquote>
    <p>Run-time error '287': Application-defined or object-defined error</p>
  </blockquote>
  
  <p>Here is the barebones code I'm trying to execute. The debugger stops on the line where I try to access the AddressEntries.</p>
  
  <pre><code>Public Sub Test()
      Dim appOL As Object
      Dim mapiNamespace As Object
      Dim GAL As AddressList, allGAL As AddressEntries
  
      Set appOL = GetObject(, "Outlook.Application")
      Set mapiNamespace = appOL.GetNamespace("mapi")
      Set GAL = mapiNamespace.AddressLists("Global Address List")
      Set allGAL = GAL.AddressEntries 'Debugger stops here
      MsgBox allGAL.Count  
  End Sub
  </code></pre>
  
  <p>Would some setting on the server be able to prevent my access to the entries of the list? Is there some other way to get the entries? My end goal is to get the entries from the list that correspond to a list of email addresses I have in an excel file and check whether each entry has a work phone # listed in its Phone Number property.</p>
  
  <p>Edit:
  <a href="https://i.stack.imgur.com/phWih.png" rel="nofollow noreferrer">Image of Outlook graying out my options</a></p>
  
  <p>Set app</p>
  
  <p>Edit2: This still gives me the same error on the second line</p>
  
  <pre><code>Set appOL = CreateObject("Outlook.Application")
  Set oGAL = appOL.GetNamespace("MAPI").AddressLists("Global Address List").AddressEntries
  </code></pre>