Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jul 2002
    Location
    Petersburg, Virginia
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access table to Outlook contacts (XP sp2)

    I found some code that is supposed to copy fields from an Access table into Outlook Contacts. The code took a long time to run, and when it was finished I had over 100 contacts. Unfortunately, the people were not from the Access table ... they all hail from Woodinville, WA! The number of contacts sometimes grows as I watch, and several parties are duplicated. Here's the code. Any thoughts?

    Function ap_CreateOLContacts()

    Dim objContactItem As ContactItem
    Dim snpContacts As DAO.Recordset
    Dim intCurrRec As Integer, intRecCount As Integer

    Application.Echo True, "Initializing to create Outlook contacts. Please wait..."

    Set snpContacts = CurrentDb.OpenRecordset("tbl_board", dbOpenSnapshot)

    '-- Get the record count for the progress meter
    snpContacts.MoveLast
    intRecCount = snpContacts.RecordCount
    snpContacts.MoveFirst

    SysCmd acSysCmdInitMeter, "Creating Outlook contacts...", intRecCount
    intCurrRec = 1

    Set olkApp = CreateObject("Outlook.Application")
    Set olkNameSpace = olkApp.GetNamespace("MAPI")

    '-- Create an Outlook contact entry for each Calypso contact record
    Do Until snpContacts.EOF
    SysCmd acSysCmdUpdateMeter, intCurrRec

    Set objContactItem = olkApp.CreateItem(olContactItem)
    With objContactItem

    .FirstName = snpContacts!FirstName
    .LastName = snpContacts!LastName
    '.BusinessAddress = snpContacts!primAddress
    ' .BusinessAddressCity = snpContacts!City
    ' .BusinessAddressState = snpContacts!State
    ' .BusinessAddressPostalCode = snpContacts!Zip
    '.BusinessTelephoneNumber = snpContacts!PhoneHome

    '-- This helps to know this Outlook contact came from Access
    .Categories = "Access Contact"

    .Save

    End With
    snpContacts.MoveNext
    intCurrRec = intCurrRec + 1
    Loop

    Set objContactItem = Nothing
    Set olkNameSpace = Nothing
    Set olkApp = Nothing

    SysCmd acSysCmdClearStatus


    End Function

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Access table to Outlook contacts (XP sp2)

    The only problem I see with the code is that the lines that create address information are commented out. Otherwise it appears the code should create a set of contacts based on the contents of the table tbl_board.
    Wendell

  3. #3
    Star Lounger
    Join Date
    Jul 2002
    Location
    Petersburg, Virginia
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access table to Outlook contacts (XP sp2)

    OK, tks. I commented out a few lines just to reduce the size of the task, trying to see if the code worked at all. I'll try running it again.

Posting Permissions

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