Access.2007.VBA.Bibl..

(John Hannent) #1
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.21 shows the exported appointments in the Outlook calendar.

FIGURE 8.21

Appointments in the Outlook calendar exported from Access.


To import appointments from your local Outlook calendar into an Access table (tblImportedCalendar),
use the following function (it can also be run from the mcrImportCalendar macro):

Public Function ImportApptsFromOutlook()

On Error GoTo ErrorHandler

Dim fldCalendar As Outlook.Folder
Dim appt As Outlook.AppointmentItem
Dim strApptName As String
Dim dteStartTime As Date
Dim dteEndTime As Date
Dim strLocation As String
Dim strSQL As String
Dim strDescription As String

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

Working with Outlook Items 8

Free download pdf