?
Solved

import outlook contacts  into excel 2003

Posted on 2011-09-20
4
Medium Priority
?
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Suggested Courses

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