I'm trying to delete all the color categories. However, the following code doesn't always delete all cases, typically leaving two or three.
Any reason it'd skip some categories?
Public Sub DeleteAllCategories()
On Error GoTo MyErrorHandler
'Assume gOutlookApp (as in Dim gOutlookApp As Outlook.Application) is valid
Dim theCategories As Outlook.Categories
Set theCategories = gOutlookApp.Session.Categories
Dim i As Long
For i = 1 To theCategories.Count
theCategories.Remove 1
DoEvents
Next
Exit Sub
MyErrorHandler:
MsgBox "DeleteAllCategories" & vbCrLf & vbCrLf & "Err = " & Err.Number & vbCrLf & "Description: " & Err.Description
End Sub
No comments:
Post a Comment