Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    9

    Unanswered: Automating Outlook Appointments

    Has anyone ever tried to automate appointments in Outlook through Access? There is an article in the KB with some code that works great, but has no information on how to set recurrances.

    I've set up a dialog box form to handle the recurrances but the coding is not working. Here's what I'm using so far that works to automate, but not to set recurrances:


    'Save record first to be sure required fields are filled.
    DoCmd.RunCommand acCmdSaveRecord

    'Exit the procedure if appointment has been added to Outlook.
    If Me!AddedToOutlook = True Then
    MsgBox "This appointment is already added to Microsoft Outlook"
    Exit Sub
    'Add a new appointment.
    Else
    Dim objOutlook As Outlook.Application
    Dim objAppt As Outlook.AppointmentItem

    Set objOutlook = CreateObject("Outlook.Application")
    Set objAppt = objOutlook.CreateItem(olAppointmentItem)

    With objAppt
    .Start = Me!ApptDate & " " & Me!ApptTime
    .Duration = Me!ApptLength
    .Subject = Me!Appt

    If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
    If Not IsNull(Me!ApptLocation) Then .Location = Me!ApptLocation
    If Me!ApptReminder Then
    .ReminderMinutesBeforeStart = Me!ReminderMinutes
    .ReminderSet = True
    End If


    .Save
    .Close (olSave)
    End With
    'Release the AppointmentItem object variable.
    Set objAppt = Nothing
    End If

    'Release the Outlook object variable.
    Set objOutlook = Nothing

    'Set the AddedToOutlook flag, save the record, display a message.
    Me!AddedToOutlook = True
    DoCmd.RunCommand acCmdSaveRecord
    MsgBox "Appointment Added!"

    Exit Sub

    Add_Err:
    MsgBox "Error " & Err.Number & vbCrLf & Err.Description
    Exit Sub
    End Sub


    Any ideas how to set the recurrance pattern on one of these? The object viewer isn't helping much unfortunately.

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne
    Posts
    2

    Re: Automating Outlook Appointments

    The code is great I have used it in an Access Client DB I am developing, however I just change one little thing to make it have a finish date and time, rather than just duration:

    Private Sub AddAppt_Click()
    On Error GoTo AddAppt_Err
    ' Save record first to be sure required fields are filled.
    DoCmd.RunCommand acCmdSaveRecord
    ' Exit the procedure if appointment has been added to Outlook.
    If Me!AddedToOutlook = True Then
    MsgBox "This appointment already added to Microsoft Outlook"
    Exit Sub
    'Add a new appointment.
    Else
    Dim oApp As Outlook.Application
    Dim oAppt As Outlook.AppointmentItem
    Set oApp = CreateObject("outlook.application")
    Set oAppt = oApp.CreateItem(olAppointmentItem)
    With oAppt
    .MeetingStatus = olMeeting
    .Subject = Me!Appt
    .Start = Me!Apptdate & " " & Me!Appttime
    .End = Me!Apptdatef & " " & Me!Appttimef
    'oAppt.Duration = Me!Apptlength
    If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
    If Not IsNull(Me!ApptLocation) Then .Location = _
    Me!ApptLocation
    If Me!ApptReminder Then
    .ReminderMinutesBeforeStart = Me!ReminderMinutes
    .ReminderSet = True
    End If

    .BusyStatus = olBusy
    .IsOnlineMeeting = False
    .AllDayEvent = False
    .Save
    End With

    Considering there is a valuetype of .RecurrenceState I imagine it would be as simple as setting the type in a format valid for that control. The following comes from MSDN to help with the control set...also there is a control of .isrecurring
    OlRecurrenceState
    olApptNotRecurring = 0
    olApptMaster = 1
    olApptOccurrence = 2
    olApptException = 3

    OlRecurrenceType
    olRecursDaily = 0
    olRecursWeekly = 1
    olRecursMonthly = 2
    olRecursMonthNth = 3
    olRecursYearly = 5
    olRecursYearNth = 6
    Last edited by nicademus; 01-14-04 at 00:47.

  3. #3
    Join Date
    Aug 2003
    Posts
    9
    Thank you so much!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •