How to create birthdays like Outlook does?

  • Thread starter Thread starter Peter Marchert
  • Start date Start date
P

Peter Marchert

Hello,

I`m trying to create birthday appointments the same way like Outlook
does if you add a birthday in a contact. With this code I´m not able
to do so:

Sub CreateBirthday()

Dim objAppointment As Outlook.AppointmentItem
Dim objRecPattern As Outlook.RecurrencePattern

Set objAppointment =
Outlook.Session.GetDefaultFolder(olFolderCalendar).Items.Add

With objAppointment
.ReminderSet = True
.Subject = "Test"
.AllDayEvent = True
.Start = CLng(27820) ' 3/1/1976
Set objRecPattern = .GetRecurrencePattern
objRecPattern.RecurrenceType = olRecursYearly
objRecPattern.PatternStartDate = CLng(27820)
objRecPattern.NoEndDate = True
.Save
End With

Set objRecPattern = Nothing
Set objAppointment = Nothing

End Sub

I expected a recurrence like:

End after:
End by: None

but I get a recurrence like this:

End after: 10
End by: Fri 3/1/1985

Is the used code wrong or does a workarround exists to get the same
result like Outlook?

I ask this question because my program creates birthday in that way
and a user have problems with the appointments after synchronizing
with his handy. May be it has to do with the way I create the items?

Btw: Setting the occurrences takes no effect
(objRecPattern.Occurrences = 1), it is still 10.

Thanks

Peter
 
Your code works prefectly fine on Outlook 2007 - weird.

Please have a closer look to the created appointment, especially to
the appointments recurrence and the posted properties.

Peter
 
Peter,

Comment out this line and try it again:

objRecPattern.NoEndDate = True
 
Thanks, Ken.

I tried it but it`s the same result. I tested it with 2003 (English)
and SP3.

Peter
 
That's odd. I tested it here with that same exact setup and got a recurring
item with no end (infinite series). Did you delete any existing instances of
that item before testing with that line commented out?
 
I resetted my virtual machine now and tried it again: same result.

You got the following properties?:

1. No end date: checked
2. End after: unchecked
3. occurrences:
4. End by: unchecked
5. End by date: None

I got this properties:

1. No end date: checked
2. End after: unchecked
3. occurrences: 10
4. End by: unchecked
5. End by date: Fri 3/1/1985

Thanks
Peter
 
The recurrence pattern I got was:

No end date: selected // these are radio controls not checkboxes
End after: unselected
End by: unselected

Yearly recurrence pattern, Start 12:00 AM, End 12:00 AM, duration 1 day,
every March 1. Start Monday March 1, 1976.

It really doesn't matter if the unselected radio controls for End after and
End by have values in them as long as they are not selected.
 
these are radio controls not checkboxes
I`m sorry, Ken.
It really doesn't matter if the unselected radio controls for End after and
End by have values in them as long as they are not selected.

I hope so. For me there is no logical reason why the appointments are
created in this way - therefore I asked.

Thank you
Peter
 
Post back if you have any problems with those recurring items with that code
line commented out, and we'll try to figure out what's going on.
 
Ok, thank you Ken.

Peter

Post back if you have any problems with those recurring items with that code
line commented out, and we'll try to figure out what's going on.









- Zitierten Text anzeigen -
 
Back
Top