如何删除所有颜色类别?
我正在尝试删除所有颜色类别。但是,以下代码并不总是删除所有案例,通常会留下两个或三个案例。
它有什么理由跳过某些类别吗?
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题有点老了,但是对于可能正在寻找相同答案的其他人......
请尝试以下操作:
This question is a little old, but for someone else who may be searching for the same answer...
Give the below a try:
我设法使用规则来做到这一点。就像如果它分配给任何类别然后删除类别,然后我在收件箱上运行它。如果您感兴趣的话,可以使用非编码解决方案!
I managed to do this using a rule. Something like if its assigned to any category then remove category, and then I ran it on my inbox. A non-coded solution if that interests you!
删除时反向循环
Reverse loop when deleting