Create appointment in Outlook - additional fields

  • Thread starter Thread starter Todd
  • Start date Start date
T

Todd

I have code that creates an Outlook appointment, but I don't know how to
change all the fields. I know how to change the subject, date, time,
length, notes, location, and reminder.

I also need to change fields like....
"Show time as... (Busy, Free, etc)"
"Recurring... (Yes/No)"
"Recurring... (Weekly, Monthly, Annually, etc)"
"Recurring... (no end date)"

Does anyone know what these fields are named? Thank you!!!
 
Hello Todd,

For "Show Time As...", check out the BusyStatus property of the
AppointmentItem object. For properties and methods associated with
Recurrence, check out the RecurrencePattern object.

Info on all of these is available in Outlook VBA Language Reference section
of Outlook|Help|Contents

hth,
 
Ok... I figured out how to do the BusyStatus change, but I don't know what
to do with the recurrence. I need code that will set the recurrence to
yearly with no end date. Can someone help me with this code? Thank you!!!
 
Todd,

Try this ...

Add the following at the top of the procedure along with your other
dimensioned variables:

Dim objApptOccur As AppointmentItem
Dim myPattern As RecurrencePattern

Insert the following *after* you have created the AppointmentItem using
CreateItem

Set myPattern = objAppt.GetRecurrencePattern
myPattern.PatternStartDate = DateAdd("yyyy", 1, Me!ApptDate)
myPattern.RecurrenceType = olRecursYearly

Note: Appears that you need to set the PatternStartDate to be a date after
the initial date of the appointment, so I have used DateAdd and presumed
that your initial Appointment Date is on a form.

hth,
 
In the code I created and tested for this, I put my code equivalent to:

If Me!ApptRecurring Then
Set myPattern = objApptOccur.GetRecurrencePattern
myPattern.PatternStartDate = DateAdd("yyyy", 1, Me!ApptDate)
myPattern.RecurrenceType = olRecursYearly
End If

directly after:

Set outappt = outobj.CreateItem(olAppointmentItem)

Try that and let me know. If it still fails, please let me know exactly
which line of code causes the failure.
 
Todd,

Had a chance to copy your code and run it in test and found that there's one
additional thing you need to change:

This line: Set myPattern = objApptOccur.GetRecurrencePattern

Should read: Set myPattern = outappt.GetRecurrencePattern

hth,
 
Back
Top