Set fldCalendar = nms.GetDefaultFolder(olFolderCalendar)
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(“tblContactsWithProjects”)
dteMonthAgo = DateAdd(“m”, -1, Date)
dteNextMonday = NextMondayTime()
With rst
Do While Not .EOF
Check whether the last meeting date is older than a month ago.
dteLastMeeting = Nz(![LastMeetingDate])
strProject = Nz(![CurrentProject])
If dteLastMeeting < dteMonthAgo Then
Create a new appointment item in the local Calendar folder.
Set appt = fldCalendar.Items.Add
appt.Subject = strProject
appt.Start = dteNextMonday
appt.Duration = “60”
appt.ReminderSet = True
appt.Body = “Monthly project meeting”
appt.Close (olSave)
End If
.MoveNext
Loop
End With
MsgBox “Outlook project meeting appointments created “
ErrorHandlerExit:
Exit Function
ErrorHandler:
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
Part II Writing VBA Code to Exchange Data between Office Components