Access.2007.VBA.Bibl..

(John Hannent) #1
Set fld = nms.Folders(“Personal Folders”)
Set fldContacts = fld.Folders(“Contacts from Access”)
If fldContacts Is Nothing Then
Set fldContacts = _
fld.Folders.Add(“Contacts from Access”, _
olFolderContacts)
End If

On Error GoTo ErrorHandler

lngContactCount = 0
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(“tblContactsToExport”)

With rst
Do While Not .EOF

Check for required name information.

strFullName = Nz(![FirstName]) & “ “ _
& Nz(![LastName])
Debug.Print “Contact name: “ & strFullName
If strFullName = “” Then
GoTo NextContact
End If

Check whether there already is an Outlook contact item for this person.

On Error Resume Next

Set conTest = fldContacts.Items(strFullName)
If conTest.FullName <> strFullName Then

No matching contact found.

Debug.Print strFullName & “ not found”
ElseIf conTest.FullName = strFullName Then
Debug.Print strFullName & “ found”
GoTo NextContact
End If

On Error GoTo ErrorHandler

lngContactID = Nz(![ContactID])
strCompanyName = Nz(![CompanyName])
strFirstName = Nz(![FirstName])
strLastName = Nz(![LastName])
strSalutation = Nz(![Salutation])
strEMail = Nz(![EmailName])
strJobTitle = Nz(![JobTitle])
strBusinessPhone = Nz(![WorkPhone]) _

Part II Writing VBA Code to Exchange Data between Office Components

Free download pdf