?
Solved

import outlook contacts  into excel 2003

Posted on 2011-09-20
4
Medium Priority
?
211 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 93

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 93

Accepted Solution

by:
Patrick Matthews earned 2000 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

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
Today as you open your Outlook, you witness an error message: “Outlook is using an old copy of your Outlook Data File…”. Probably, Outlook is accessing an old OST file.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

864 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