recurrence pattern - every weekday + redemption

  • Thread starter Eddy d'Artois via OfficeKB.com
  • Start date
E

Eddy d'Artois via OfficeKB.com

I'm using vba to open make an invitation with recurrence pattern. When I'm
trying to set an daily recurrence on weekday's, the value should be 62 as
Sue Mosher told me. But when I run the code, I get an error on the
property.
Can anybody help me to resolve this error ?

Thanks

code:

Private Sub imgInvitation_Click()
Dim objOL 'As Outlook.Application
Dim objAppt 'As Outlook.AppointmentItem
Dim MyPattern
Dim SafeApp
Dim rst1 As New ADODB.Recordset
Dim rstRec As New ADODB.Recordset
Dim strAttendees As String
Dim strBody, strZaal As String
'we halen alle attendees op
rst1.Open "tblAttendeesTmp", CurrentProject.Connection, adOpenKeyset,
adLockPessimistic
If rst1.EOF And rst1.BOF Then Exit Sub
Do Until rst1.EOF

If strAttendees = "" Then
strAttendees = rst1!Attendee_Mail
Else
strAttendees = strAttendees & ";" & rst1!Attendee_Mail
End If
rst1.MoveNext
Loop
rst1.Close
Const olAppointmentItem = 1
Const olMeeting = 1

Set objOL = CreateObject("Outlook.Application")
Set SafeApp = CreateObject("Redemption.SafeAppointmentItem")
Set objAppt = objOL.CreateItem(olAppointmentItem)

SafeApp.Item = objAppt

With SafeApp
.Subject = "Meeting Invitation For " & Forms!
frmAanvraag.txtOnderwerp
.start = Forms!frmAanvraag.txtDatum & " " & Forms!
frmAanvraag.cboStartuur
.End = Forms!frmAanvraag.txtDatum & " " & Forms!
frmAanvraag.cboEinduur
strZaal = DLookup("[Zaal]", "tblZalen", "[ZaalID]= " & Forms!
frmAanvraag.txtZaalID)
.Location = strZaal
.MeetingStatus = olMeeting
strBody = "You are invited for the meeting " & Forms!
frmAanvraag.txtOnderwerp
strBody = strBody & Chr(13) & "Meeting Room: " & strZaal
strBody = strBody & Chr(13) & "Start: " & Format(Forms!frmAanvraag!
cboStartuur, "hh:nn")
strBody = strBody & Chr(13) & "End: " & Format(Forms!frmAanvraag!
cboEinduur, "hh:nn")
If Forms!frmAanvraag!txtRecurrence = "None" Then
strBody = strBody & Chr(13) & "Date: " & rstRec!Startdatum
Else
strBody = strBody & Chr(13) & Forms!frmAanvraag!txtRecurrence
End If
.Body = strBody
.RequiredAttendees = strAttendees
If Forms!frmAanvraag!txtRecurrence <> "None" Then 'indien
recurrence vullen we het pattern in
Set MyPattern = .GetRecurrencePattern
'Hier halen we de info uit de tblRecurrency
rstRec.Open "tblRecurrency", CurrentProject.Connection,
adOpenKeyset, adLockPessimistic
Select Case rstRec!Pattern
Case Is = 2 'dagelijks
MyPattern.RecurrenceType = olRecursDaily
MyPattern.DayOfWeekMask = 62 '******here I get the
error
MyPattern.Interval = 1
MyPattern.PatternStartDate = rstRec!Startdatum
MyPattern.PatternEndDate = rstRec!EindDatum
MyPattern.Occurrences = rstRec!AantalRecs

Case Is = 3 'wekelijks
MyPattern.RecurrenceType = 1
MyPattern.Interval = rstRec!Weken
MyPattern.PatternStartDate = rstRec!Startdatum
MyPattern.PatternEndDate = rstRec!EindDatum
MyPattern.Occurrences = rstRec!AantalRecs
Select Case rstRec!weekdag
Case Is = "Monday"
MyPattern.DayOfWeekMask = 2
Case Is = "Tuesday"
MyPattern.DayOfWeekMask = 4
Case Is = "Wednesday"
MyPattern.DayOfWeekMask = 8
Case Is = Thursday
MyPattern.DayOfWeekMask = 16
Case Is = "Friday"
MyPattern.DayOfWeekMask = 32
End Select
Case Is = 4 'maandelijks
MyPattern.RecurrenceType = 3
MyPattern.Interval = 1
MyPattern.PatternStartDate = rstRec!Startdatum
MyPattern.PatternEndDate = rstRec!EindDatum
MyPattern.Occurrences = rstRec!AantalRecs
Select Case rstRec!weekdag
Case Is = "Monday"
MyPattern.DayOfWeekMask = 2
Case Is = "Tuesday"
MyPattern.DayOfWeekMask = 4
Case Is = "Wednesday"
MyPattern.DayOfWeekMask = 8
Case Is = Thursday
MyPattern.DayOfWeekMask = 16
Case Is = "Friday"
MyPattern.DayOfWeekMask = 32
End Select
MyPattern.Instance = fZoveelste(rstRec!EindDatum)
End Select
End If
If SafeApp.Recipients.ResolveAll Then
.Display
End If
End With

Set objAppt = Nothing
Set objOL = Nothing

End Sub
 
D

Dan Mitchell

I'm using vba to open make an invitation with recurrence pattern.
When I'm trying to set an daily recurrence on weekday's, the value
should be 62 as Sue Mosher told me. But when I run the code, I get an
error on the property.

MyPattern.RecurrenceType = olRecursDaily
MyPattern.DayOfWeekMask = 62 '******here I get

That's because if you want to set DayOfWeekMask, you need to set it to a
weekly recurrence, not a daily one.

-- dan
 
E

Eddy d'Artois via OfficeKB.com

Dan,

I don't understand: When I make an appointment (manual - not with code) I
only see the possiblity of "Every Weekday" when I click the option "Daily".
(We have outlook 2000 at the office)in the Appointment recurrence pattern.

Eddy
 
K

Ken Slovak - [MVP - Outlook]

The recurrence builder UI doesn't necessarily match what you must do in
code. Outlook takes care of that for you under the hood. Dan is correct as
to the recurrence pattern you must use.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DELETING ORPHANED RECORDS 0
Loop Problems 1

Top