Results 1 to 9 of 9

Thread: Import Outlook Contacts (Resolved)

  1. #1

    Thread Starter
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627

    Import Outlook Contacts (Resolved)

    Does anyone have any tips/links/samples for importing Outlook 2002 Contacts into an Access 2002 database?

    Thanks in advance
    Last edited by demotivater; Sep 16th, 2003 at 03:05 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    In Outlook, with the Contacts being displayed...
    Click File > Import and Export... > Then the wizard pops up.
    Export to a File > Microsoft Access > Select Contacts folder.
    Then browse to your access database. Then click Finish.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627
    Should have been more clear, I'm attempting to do this through vb6 code. Thanks for the input though.

  4. #4
    Junior Member
    Join Date
    Mar 2000
    Location
    Louisville, KY
    Posts
    21
    Hi Michelle !

    You can use the Outlook Object Library to Access the contacts.

    You can look at the example given in the link
    http://support.microsoft.com/?kbid=260999


    Hope it Helps
    Shubha
    Shubhabrata De

  5. #5

    Thread Starter
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627
    No sure who Michelle is??
    But thanks for the link, I never have any luck searching M$ site.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Linked Contacts are for internal use by Outlook and not for Access.
    Try this...Connect to Outlook Contacts using ADO and import into Access.
    VB Code:
    1. Public Function Outlook_Contacts_2_Access()
    2. '   <GORS = ACCESS>
    3. '   <ORS = OUTLOOK>
    4.     On Error GoTo No_Bugs
    5.    
    6.     Dim Cnn As ADODB.Connection
    7.     Dim CnnA As ADODB.Connection
    8.     Dim oRs As ADODB.Recordset
    9.     Dim goRs As ADODB.Recordset
    10.  
    11.     Dim sSQL As String
    12.    
    13.     Set Cnn = New ADODB.Connection
    14.     Set CnnA = New ADODB.Connection
    15.     Set oRs = New ADODB.Recordset
    16.     Set goRs = New ADODB.Recordset
    17.  
    18.     Cnn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Exchange 4.0;" & _
    19.     "MAPILEVEL=Outlook Address Book\;TABLETYPE=1;" & _
    20.     "DATABASE={B1C82C96-7149-4EDD-A709-8D7E66518332}" 'PROFILE=Outlook;
    21.     Cnn.Open
    22.    
    23.     sSQL = "SELECT * from [Contacts]"
    24.    
    25.     oRs.Open sSQL, Cnn, adOpenStatic, adLockReadOnly, adCmdText
    26.  
    27.     CnnA.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\OtoA.mdb;Persist Security Info=False"
    28.     CnnA.Open
    29.     goRs.Open "SELECT * FROM Contacts WHERE 1=2;", CnnA, adOpenStatic, adLockReadOnly, adCmdText
    30.    
    31.     frmMain.prbProgress.Max = oRs.RecordCount
    32.     oRs.MoveFirst
    33.     i = 0
    34.     Do While oRs.EOF = False
    35.         DoEvents
    36.         goRs.AddNew
    37.         goRs!First = oRs!First
    38.         goRs!Last = oRs!Last
    39.         goRs!Title = oRs!Title
    40.         goRs!Company = oRs!Company
    41.         goRs!Department = oRs!Department
    42.         goRs!Office = oRs!Office
    43.         goRs.Fields("Post Office Box") = oRs.Fields("Post Office Box")
    44.         goRs!Address = oRs!Address
    45.         goRs!City = oRs!City
    46.         goRs!State = oRs!State
    47.         goRs.Fields("Zip Code") = oRs.Fields("Zip Code")
    48.         goRs!Country = oRs!Country
    49.         goRs!Phone = oRs!Phone
    50.         goRs.Fields("Mobile Phone") = oRs.Fields("Mobile Phone")
    51.         goRs.Fields("Pager Phone") = oRs.Fields("Pager Phone")
    52.         goRs.Fields("Home2 Phone") = oRs.Fields("Home2 Phone")
    53.         goRs.Fields("Assistant Phone Number") = oRs.Fields("Assistant Phone Number")
    54.         goRs.Fields("Fax Number") = oRs.Fields("Fax Number")
    55.         goRs.Fields("Telex Number") = oRs.Fields("Telex Number")
    56.         goRs.Fields("Display Name") = oRs.Fields("Display Name")
    57.         goRs.Fields("E-mail Type") = oRs.Fields("E-mail Type")
    58.         goRs.Fields("E-mail Address") = oRs.Fields("E-mail Address")
    59.         goRs!Alias = oRs!Alias
    60.         goRs!Assistant = oRs!Assistant
    61.         goRs.Fields("Send Rich Text") = oRs.Fields("Send Rich Text")
    62.         goRs!Primary = oRs!Primary
    63.         goRs.Update
    64.         oRs.MoveNext
    65.         i = i + 1
    66.         frmMain.prbProgress.Value = i
    67.     Loop
    68.     oRs.Close
    69.     goRs.Close
    70.     Set Cnn = Nothing
    71.     Set CnnA = Nothing
    72.     Set oRs = Nothing
    73.     Set goRs = Nothing
    74.     Exit Function
    75.  
    76. No_Bugs:
    77.    
    78.     If Err.Number = "-2147467259" Then
    79.         MsgBox "User Canceled Operation!", vbInformation + vbOKOnly, "Outlook Contacts Connect"
    80.         Set Cnn = Nothing
    81.         Set CnnA = Nothing
    82.         Set oRs = Nothing
    83.         Set goRs = Nothing
    84.         Exit Function
    85.     ElseIf Err.Number = "-2147217865" Then
    86.         MsgBox "Invalid Profile Entered!", vbInformation + vbOKOnly, "Outlook Contacts Connect"
    87.         Set Cnn = Nothing
    88.         Set CnnA = Nothing        
    89.         Set oRs = Nothing
    90.         Set goRs = Nothing
    91.         Exit Function
    92.     Else
    93.         MsgBox Err.Number & "-" & Err.Description, vbCritical, "Outlook Contacts Connect"
    94.         Resume Next
    95.     End If
    96.  
    97. End Function
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Oh ya, just create the Contacts table in Access with the fileds you
    want to import. Then in the code remove the fields so the code
    matches your table's fields. Set the proper field types too.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627
    Sweet
    Thanks man, that's exactly what I needed.

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Your welcome. The only thing is that it is slow if you have alot of contacts in Outlook.
    No way around that though.

    Later.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width