excelvbaoutlookoffice-automationgal

Can I reach Global Address List language independently?



I would like to create an excel tool which at some point of the operation opens the Global Address List of the Outlook. I have figured it out how to do this, but there was an issue when we tried it on a German languaged computer. I have solved it by check the UI language prior to opening the address book, but I wondered if there is a language independent way to do so? (So I don't need to create a case for every possible languages.)
My corresponding code portion is:
langCode=Application.LanguageSettings.LanguageID(msoLanguageIDUI)
Select Case langCode
 Case &H409
  galStr="Global Address List"
 Case &H40E
  galStr="Globális címlista"
 Case &H407
  galStr="Globale Addressliste"
 Case Else
  galStr="Global Address List"
End Select 

Set olApp=GetObject(,"Outlook.Application")

Set olGAL=olApp.GetNamespace("MAPI"). AddressLists(galStr)

Many thanks for your help.


Solution

  • Use Namespace.GetGlobalAddressList - it will return the GAL of the primary Exchange account in the profile.

    As for the AddrList.AddressListType property, it will return olExchangeGlobalAddressList only for the GAL of the primary Exchange account. For a secondary account, it will be a generic olExchangeContainer.

    If you have more than one Exchange account in the profile, you can figure out if a particular address list is GAL by reading two MAPI properties using AddressList.PropertyAccessor: PR_AB_PROVIDER_ID must be "DCA740C8C042101AB4B908002B2FE182"and PR_DISPLAY_TYPE must be DT_GLOBAL (0x00020000).

    If using Redemption (I am its author) is an option, besides exposing RDOSession.Addressbook.GAL (similar to Namespace.GetGlobalAddressList in OOM), it also exposes RDOExchangeAccount.GAL property on the account level (AllRooms property is also exposed).