Sunday, 27 November 2016

vba - How Can You Delete All Color Categories?

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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...