Solved

import outlook contacts  into excel 2003

Posted on 2011-09-20
4
194 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

770 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