Outlook is not running; open Outlook with CreateObject.
If Err.Number = 429 Then
Set appOutlook = CreateObject(“Outlook.Application”)
Resume Next
Else
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit
End If
End Function
Figure 8.22 shows the table of imported appointments, which is automatically opened at the end
of the procedure.
FIGURE 8.22
A table of appointments imported from an Outlook calendar folder.
For a more realistic scenario, in which you want to create appointments based on data in an Access
table of project data, use the CreateProjectApptsfunction (it can also be run from the
mcrCreateProjectAppts macro). This function selects records in tblContactsWithProjects that have
a last meeting date older than a month ago, and creates an Outlook appointment for a project
meeting for the following Monday for each of those records, writing data from several fields in the
Access record to the appointment item:
Public Function CreateProjectAppts()
On Error GoTo ErrorHandler
Dim fldCalendar As Outlook.Folder
Dim appt As Outlook.AppointmentItem
Dim dteMonthAgo As Date
Dim dteLastMeeting As Date
Dim dteNextMonday As Date
Dim strProject As String
Set appOutlook = GetObject(, “Outlook.Application”)
Set nms = appOutlook.GetNamespace(“MAPI”)
Working with Outlook Items 8