Solved

import outlook contacts  into excel 2003

Posted on 2011-09-20
4
189 Views
Last Modified: 2012-05-12
Looking to code a button in excel to pull all my contacts from outlook into excel.
I would like to automate it so it runs by its self but will do it with a button..
This is for outlook and excel 2003… Please help.
0
Comment
Question by:cdb424ttm
  • 2
  • 2
4 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 36568059
Outlook has a native capability to export your contacts to Excel.  Why not just use that?

Import / Export under File in the menu...
0
 

Author Comment

by:cdb424ttm
ID: 36568305
explain how I do this please, I tying to automate it so it check 3 or 4 times a day and keeps updating it's self...
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 36568925
OK, the following code when run from Excel will grab the contacts from Outlook.

Sub GrabTheContacts()
    
    Dim olApp As Object 'Outlook.Application
    Dim olFolder As Object 'Outlook.Folder
    Dim olItem As Object
    Dim DestR As Long
    Dim LastName As String
    
    Const olFolderContacts As Long = 10
    Const olContact As Long = 40
    
    Application.ScreenUpdating = False
    
    Workbooks.Add
    [a1:f1].Value = Array("LName", "FName", "Company", "Email1", "Office Phone", "Mobile Phone")
    DestR = 1
    
    Set olApp = CreateObject("Outlook.Application")
    Set olFolder = olApp.GetNamespace("Mapi").GetDefaultFolder(olFolderContacts)
    
    For Each olItem In olFolder.Items
        If olItem.Class = olContact Then
            DestR = DestR + 1
            With olItem
                LastName = Trim(.LastName)
                If LastName = "" Then LastName = "<none>"
                Cells(DestR, 1).Resize(1, 6) = Array(LastName, .FirstName, .CompanyName, .Email1Address, _
                    .BusinessTelephoneNumber, .MobileTelephoneNumber)
            End With
        End If
    Next
    
    [a1].Sort Key1:=[a1], Key2:=[b1], Order1:=xlAscending, Order2:=xlAscending, Header:=xlYes
    Application.ScreenUpdating = True
    MsgBox "Done"
    
End Sub

Open in new window

0
 

Author Closing Comment

by:cdb424ttm
ID: 36576929
Thanks for the quick response!! good work!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Use email signature images to promote corporate certifications and industry awards.
Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now