Access.2007.VBA.Bibl..

(John Hannent) #1
If you have a set of linked Access tables of contact data, and you want to keep the data
in the tables synchronized with matching Outlook contact items, you need more than a
simple export. See Chapter 11 for a discussion of two-way synchronizing between Access and
Outlook contacts.

To export data from an Access flat-file contacts table (such as tblContactsToExport) to Outlook
contacts in a custom Contacts folder called Contacts from Access, use the function listed as follows
(it can also be run from the mcrExportFlatFileContactsToOutlook macro):

Public Function ExportFlatFileContactsToOutlook()

On Error GoTo ErrorHandler

Set appOutlook = GetObject(, “Outlook.Application”)

Dim lngContactID As Long
Dim lngContactCount As Long
Dim fld As Outlook.Folder
Dim fldContacts As Outlook.Folder
Dim conNew As Outlook.ContactItem
Dim conTest As Outlook.ContactItem
Dim strFullName As String
Dim strFirstName As String
Dim strLastName As String
Dim strBusinessPhone As String
Dim strMobilePhone As String
Dim strFaxNumber As String
Dim strNotes As String
Dim strJobTitle As String
Dim strStreetAddress As String
Dim strCity As String
Dim strStateProv As String
Dim strPostalCode As String
Dim strCountry As String
Dim strCompanyName As String
Dim strEMail As String
Dim strSalutation As String

Set appOutlook = GetObject(, “Outlook.Application”)
Set nms = appOutlook.GetNamespace(“MAPI”)

Use the following line to export to the default local Contacts folder:

‘Set fldContacts = nms.GetDefaultFolder(olFolderTasks)

On Error Resume Next

Use the following lines to export to a custom Contacts folder, creating it if necessary. If setting a
reference to the folder fails, the folder will be created.

CROCROSSSS-REF-REF


Working with Outlook Items 8

Free download pdf