Try using And: If DayMask And OlDaysOfWeek.olSunday Then
, etc.
How do I interogate event.GetRecurrencePattern.DayOfWeekMask in VBA?
jonathan small
1
Reputation point
I have VBA code in Outlook which is looking at events and tries to create an Rrule day string. This is the code I am executing:
Function ConvertDaysOfTheWeek(ByVal DayMask As Integer) As String
Dim sDaysOfTheWeek As String
sDaysOfTheWeek = ""
If (DayMask & OlDaysOfWeek.olSunday) Then
sDaysOfTheWeek = ",SU"
End If
If (DayMask & OlDaysOfWeek.olMonday) Then
sDaysOfTheWeek = sDaysOfTheWeek + ",MO"
End If
If (DayMask & OlDaysOfWeek.olTuesday) Then
sDaysOfTheWeek = sDaysOfTheWeek + ",TU"
End If
If (DayMask & OlDaysOfWeek.olWednesday) Then
sDaysOfTheWeek = sDaysOfTheWeek + ",WE"
End If
If (DayMask & OlDaysOfWeek.olThursday) Then
sDaysOfTheWeek = sDaysOfTheWeek + ",TH"
End If
If (DayMask & OlDaysOfWeek.olFriday) Then
sDaysOfTheWeek = sDaysOfTheWeek + ",FR"
End If
If (DayMask & OlDaysOfWeek.olSaturday) Then
sDaysOfTheWeek = sDaysOfTheWeek + ",SA"
End If
If Len(sDaysOfTheWeek) > 1 Then
sDaysOfTheWeek = Right(sDaysOfTheWeek, Len(sDaysOfTheWeek) - 1)
End If
ConvertDaysOfTheWeek = sDaysOfTheWeek
End Function
The value of 37 is being passed to the function and the function should return "SU,TU,FR". Instead, it is returning "SU,MO,TU,WE,TH,FR,SA".
How do I set up the condition to pick up the proper days of the week?
Thank you.
1 answer
Sort by: Most helpful
-
Viorel 119.2K Reputation points
2023-01-06T22:10:04.95+00:00