JamesMeadlock
Technical User
I've been trying for about 8 hours to figure this out:
I've tried to deduce what this support article says:
I'm getting CRAZY results... I'll include code & part of what it prints to the debug window... questions it raises for me:
1) Why does the count increase to the millions after a sort operation?
2) Why, when I try to access a reccurrence, does it raise an error?
3) GetRecurrencePattern only returns 1 or 0... that's not very useful
Thanks for any help!
The code:
Sub DoIt()
Dim olMAPI As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder
Dim colItems As Outlook.Items
Dim objItem As Outlook.AppointmentItem
Set olMAPI = GetObject("", "Outlook.Application".GetNamespace("MAPI"
Set Folder = olMAPI.Folders("Public Folders".Folders("All Public Folders".Folders("Entertainment"
Set colItems = Folder.Items
colItems.IncludeRecurrences = True
Debug.Print "#Items:" & colItems.Count
colItems.Sort "[Start]"
Debug.Print "#Items:" & colItems.Count
For Each objItem In colItems
Debug.Print objItem.Subject
Debug.Print objItem.IsRecurring
Debug.Print objItem.GetRecurrencePattern
If objItem.GetRecurrencePattern = True Then
Debug.Print "-->" & objItem(1).Subject
End If
Next
'Cleanup
Set olMAPI = Nothing
Set Folder = Nothing
Set colItems = Nothing
End Sub
The wacky results:
DoIt
#Items:10
#Items:2147483647
Steve Taylor
True
0
Shelly & Dave
True
1
Holly & Dave
True
1
DJ
True
1
Steve Taylor
True
0
I've tried to deduce what this support article says:
I'm getting CRAZY results... I'll include code & part of what it prints to the debug window... questions it raises for me:
1) Why does the count increase to the millions after a sort operation?
2) Why, when I try to access a reccurrence, does it raise an error?
3) GetRecurrencePattern only returns 1 or 0... that's not very useful
Thanks for any help!
The code:
Sub DoIt()
Dim olMAPI As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder
Dim colItems As Outlook.Items
Dim objItem As Outlook.AppointmentItem
Set olMAPI = GetObject("", "Outlook.Application".GetNamespace("MAPI"
Set Folder = olMAPI.Folders("Public Folders".Folders("All Public Folders".Folders("Entertainment"
Set colItems = Folder.Items
colItems.IncludeRecurrences = True
Debug.Print "#Items:" & colItems.Count
colItems.Sort "[Start]"
Debug.Print "#Items:" & colItems.Count
For Each objItem In colItems
Debug.Print objItem.Subject
Debug.Print objItem.IsRecurring
Debug.Print objItem.GetRecurrencePattern
If objItem.GetRecurrencePattern = True Then
Debug.Print "-->" & objItem(1).Subject
End If
Next
'Cleanup
Set olMAPI = Nothing
Set Folder = Nothing
Set colItems = Nothing
End Sub
The wacky results:
DoIt
#Items:10
#Items:2147483647
Steve Taylor
True
0
Shelly & Dave
True
1
Holly & Dave
True
1
DJ
True
1
Steve Taylor
True
0