vbaoutlookaddressbook

How to open contact list with VBA


How can I use VBA to do the same thing as Ctrl+Shift+B, Tools, Options, Custom and set a specific contact list as number one?


Solution

  • You cannot do that in VBA - Outlook Object Model does not expose that functionality.

    In Extended MAPI (C++ or Delphi), use IAddrBook.SetDefaultDir and set the PR_AB_CHOOSE_DIRECTORY_AUTOMATICALLY property appropriately.

    If using Redemption (any language - I am its author) is an option, you can use the RDOAddressBook.DefaultAddressList property:

    set Session = CreateObject("Redemption.RDOSession")
    Session.MAPIOBJECT = Application.Session.MAPIOBJECT
    set AddrList = Session.AddressBook.AddressLists.Item("Contacts")
    Session.AddressBook.DefaultAddressList = AddrList