View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Steve Yandl Steve Yandl is offline
external usenet poster
 
Posts: 284
Default Importing Outlook contacts into Excel (2003)

Trish,

If you're not able to open Outlook, I have my doubts this subroutine will
work but it's worth trying. If it does work, you will get a warning window
telling you that a program is trying to access Outlook information and you
will need to give permission for a certain number of minutes. If it doesn't
work, you will need to consider moving pst files to a PC where Outlook is
working.

If you've never created a macro or subroutine, click on Alt plus F8 as a
first step. Where it asks for 'Macro name', type in a name using letters
with no spaces and then click the 'Create' button. The Visual Basic Editor
window will pop up with a Sub() and End Sub line entered for you. Between
the Sub() and End Sub lines, copy and paste what I have between the lines
below. Close the Visual Basic Editor window, press Alt plus F8 again and
select the macro we just created. This time click the 'Run' button and see
if the routine works. If it does work, it can be expanded to retrieve more
contact information than just the full name, email address and phone number
of each contact. We can also create a similar routine to recover
distribution lists and a detail of the members in each.

' /////////////////////////////////////////////////
Dim R As Integer

Const olFolderContacts = 10

On Error Resume Next

R = 1

Set objOL = CreateObject("Outlook.Application")
Set objNS = objOL.GetNamespace("MAPI")

Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items

For Each myContact In colContacts
If TypeName(myContact) = "ContactItem" Then
Cells(R, 1).Value = myContact.FullName
Cells(R, 2).Value = myContact.Email1Address
Cells(R, 3).Value = myContact.PrimaryTelephoneNumber
R = R + 1
End If
Next myContact

Set objNS = Nothing
Set objOL = Nothing

' ////////////////////////////////////////////

Steve Yandl




"Trish" wrote in message
...
Hi, we have a major problem with Outlook (to the point that we cannot even
open it) and would like to obtain a copy of our address book. We would
like
to import it into Excel (.csv or something). The instructions we have
found
say we need to open Outlook first, which we cannot. Is there a
workaround?
Hope you can help. Many thanks. Trish