+ Reply to Thread
Results 1 to 2 of 2

VBA scipt doesnt get all contacts from Outlook

  1. #1
    Registered User
    Join Date
    05-20-2021
    Location
    CH
    MS-Off Ver
    2019
    Posts
    0

    VBA scipt doesnt get all contacts from Outlook

    Hi all

    i need all my Conctacts (2500) but only the data below

    Sub ExportOutlookAddressBook()
    'DEVELOPER: Ryan Wells (wellsr.com)
    'DESCRIPTION: Exports your Outlook Address Book to Excel.
    'NOTES: This macro runs on Excel.
    ' Add the Microsoft Outlook Reference library to the project to get this to run
    Application.ScreenUpdating = False
    Dim olApp As Outlook.Application
    Dim olNS As Outlook.Namespace
    Dim olAL As Outlook.AddressList
    Dim olEntry As Outlook.AddressEntry
    Set olApp = Outlook.Application
    Set olNS = olApp.GetNamespace("MAPI")
    Set olAL = olNS.AddressLists("Contacts") 'Change name if different contacts list name
    ActiveWorkbook.ActiveSheet.Range("a5").Select
    For Each olEntry In olAL.AddressEntries
    ' your looping code here
    ActiveCell.Value = olEntry.GetContact.Gender 'gender
    ActiveCell.Offset(0, 1).Value = olEntry.GetContact.FirstName 'firstname
    ActiveCell.Offset(0, 2).Value = olEntry.GetContact.LastName 'lastname
    ActiveCell.Offset(0, 3).Value = olEntry.GetContact.CompanyName 'company
    ActiveCell.Offset(0, 4).Value = olEntry.GetContact.JobTitle 'function
    ActiveCell.Offset(0, 5).Value = olEntry.GetContact.MobileTelephoneNumber 'phonenumber
    ActiveCell.Offset(0, 6).Value = olEntry.GetContact.Email1Address 'email
    ActiveCell.Offset(0, 7).Value = olEntry.GetContact.BusinessAddress 'adress
    ActiveCell.Offset(1, 0).Select
    DoEvents
    Next olEntry
    Set olApp = Nothing
    Set olNS = Nothing
    Set olAL = Nothing
    Application.ScreenUpdating = True
    End Sub

    it outputs around 1000 contacts even if they all under the same folder (Contacts)
    even worst when i saw that there some contacts that where listed twice :/

    thanks for your help guys

    kr
    Chichox

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166
    Hello Chichox,

    Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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. Replies: 2
    Last Post: 03-03-2019, 02:50 AM
  2. [SOLVED] Retrieving Contacts from Outlook
    By rad2085 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2014, 06:20 PM
  3. Search Outlook Contacts
    By plans in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-08-2014, 07:54 PM
  4. Too many duplicate Outlook Contacts
    By kgandhi in forum Excel General
    Replies: 1
    Last Post: 02-23-2010, 07:17 PM
  5. [SOLVED] Outlook Contacts Pop-up
    By evanzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2010, 10:35 AM
  6. Sharing contacts with outlook express and outlook
    By champs in forum Outlook Formatting & Functions
    Replies: 2
    Last Post: 02-27-2009, 05:29 AM
  7. outlook contacts
    By lee in forum Excel General
    Replies: 0
    Last Post: 10-25-2005, 04:05 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