+ Reply to Thread
Results 1 to 2 of 2

Macro to pull from GAL based on excel values

  1. #1
    Registered User
    Join Date
    05-16-2016
    Location
    Abu Dhabi
    MS-Off Ver
    2013
    Posts
    1

    Macro to pull from GAL based on excel values

    Hi there,

    I would like to find out if its possible to pull outlook contact information (department, full name, company name, telephone number, alias, mobile number - in that order) from the global address book into Excel 2013 based on employee email address.

    For example, in Column A I will have a range of email addresses and from there, run a macro to fill out the above mentioned fields.

    I have the found the following code that pulls information based on User ID but I am having trouble modifying the code:

    ---
    Public Sub GetUsers()

    Dim myolApp As Outlook.Application
    Dim myNameSpace As Namespace
    Dim myAddrList As AddressList
    Dim myAddrEntry As addressEntry
    Dim AliasName As String
    Dim i As Integer, r As Integer
    Dim c As Range
    Dim EndRow As Integer, n As Integer
    Dim exchUser As Outlook.ExchangeUser

    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 HomeState As String, PhoneNum As String
    Dim StartRow As Integer

    EndRow = Cells(Rows.Count, 3).End(xlUp).Row

    StartRow = InputBox("At which row should this start?", "Start Row", 2)

    For Each c In Range("A" & StartRow & ":A" & CStr(EndRow))
    AliasName = LCase(Trim(c))
    c = AliasName
    Set myAddrEntry = myAddrList.addressEntries(AliasName)
    Set exchUser = myAddrEntry.GetExchangeUser

    If Not exchUser Is Nothing Then
    FirstName = exchUser.FirstName
    LastName = exchUser.LastName
    HomeState = exchUser.StateOrProvince
    PhoneNum = exchUser.BusinessTelephoneNumber

    End If

    Next c
    End Sub
    ---

    Any assistance will be greatly appreciated

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Macro to pull from GAL based on excel values

    You forgot the code tags => update your thread
    - Battle without fear gives no glory - Just try

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro / formula to pull values from cells based on headers
    By Hypex in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2016, 07:36 AM
  2. Replies: 7
    Last Post: 02-12-2016, 05:30 AM
  3. Pull in data based on certain values
    By joemand in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 06-02-2014, 04:59 PM
  4. Pull in data based on certain values
    By jruiz1120 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-19-2014, 09:52 AM
  5. Pull Data from Excel Worksheet to Another Based on Defined Values
    By HjMcLean in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-16-2013, 02:31 PM
  6. Need Macro to pull data from one excel sheet to another based on a job# and comparing date
    By electromattnic in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2013, 04:10 AM
  7. Replies: 1
    Last Post: 12-08-2005, 04:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1