O'Reilly logo

Access Data Analysis Cookbook by Wayne S. Freeze, Ken Bluttman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Importing Appointments from the Outlook Calendar

Problem

Is there a way that I can import information from my Outlook calendar into an Access table?

Solution

To import your data, you'll first need to build a table to hold the information. Table 7-2 lists the fields associated with Outlook's calendar appointments that you'll need to include in your table.

Table 7-2. Fields in the Outlook calendar table

Field

Data type

Id

AutoNumber

Start

Date/Time

End

Date/Time

Subject

Text(255)

Location

Text(255)

Body

Memo

Duration

Number(Long Integer)

RequiredAttendees

Text(255)

OptionalAttendees

Text(255)

Resources

Text(255)

Next, you'll need to add a reference to the Outlook Object Library (see Figure 7-2adding_the_outlook_object_library_to_your_application). To display the References dialog, choose Tools → References from the Visual Basic Editor's main menu.

Adding the Outlook Object Library to your application

Figure 7-20. Adding the Outlook Object Library to your application

Finally, here is a routine that will do the work. It begins by declaring a bunch of variables needed to access Outlook's data, plus an ADO Recordset object that will be used to save the information into Access:

	Sub Example7_15()

	Dim Outlook As Outlook.Application
	Dim namespace As Outlook.namespace
	Dim root As Outlook.MAPIFolder
	Dim cal As Outlook.MAPIFolder

	Dim item As Object
	Dim appt AsOutlook.AppointmentItem Dim rs As ADODB.Recordset Set Outlook = New Outlook.Application ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required