Skip to main content

如何清除Outlook中的所有類別?

Author: Xiaoyang Last Modified: 2025-05-13

假設您的Outlook中有很多項目都應用到了顏色類別。如果您需要從這些項目中清除所有這些類別,該如何快速輕鬆地在Outlook中完成這項工作呢?

使用「清空所有類別」功能從特定文件夾清除所有類別

使用VBA代碼從特定帳號清除所有類別


使用「清空所有類別」功能從特定文件夾清除所有類別

如果您只需要清除特定文件夾中的類別,請按照以下步驟操作:

1. 點擊您要移除顏色類別的文件夾,然後按 Ctrl + A 選擇所有項目。

2. 然後右鍵點擊,選擇「新增類別」>「清空所有類別」於快捷選單中,詳見截圖:

doc clear category 1

3. 接著,這個特定文件夾中的所有顏色類別將一次性被清除。


使用VBA代碼從特定帳號清除所有類別

要從一個帳號的所有項目(例如郵件、任務、聯繫人、便簽等)中清除所有類別,下面的VBA代碼可以幫助您:

1. 點擊您想清理所有類別的帳號郵件,然後按住 ALT + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。

2. 點擊「插入」 > 「模組」,並將以下宏粘貼到模組窗口中。

VBA代碼:從特定帳號清除所有類別:

Sub BatchClearAllCategories_AllOutlookItems()
    Dim xCurrentFolder As Outlook.Folder
    Dim xFolder As Folder, xCurFolder As Folder
    Dim xPos As Integer
    Dim xRootFldName As String
    Set xCurFolder = Outlook.ActiveExplorer.CurrentFolder
    xPos = InStr(3, xCurFolder.FolderPath, "\")
    If xPos > 0 Then
        xRootFldName = Mid(xCurFolder.FolderPath, 3, xPos - 3)
    Else
        xRootFldName = Mid(xCurFolder.FolderPath, 3, Len(xCurFolder.FolderPath) - 2)
    End If
    Set xCurrentFolder = Outlook.Application.Session.Folders(xRootFldName)
    For Each xFolder In xCurrentFolder.Folders
        Call ProcessFolders(xFolder)
    Next
    MsgBox "Clear completed!", vbInformation + vbOKOnly, "Kutools for Outlook"
End Sub
Sub ProcessFolders(ByVal CurFld As Outlook.Folder)
    Dim xItem As Object
    Dim i As Integer
    Dim xSubfolder As Outlook.Folder
    If CurFld.Items.Count > 0 Then
        For i = CurFld.Items.Count To 1 Step -1
            Set xItem = CurFld.Items.Item(i)
            xItem.Categories = ""
            xItem.Save
        Next
    End If
    If CurFld.Folders.Count = 0 Then Exit Sub
    For Each xSubfolder In CurFld.Folders
        Call ProcessFolders(xSubfolder)
    Next
End Sub

3. 然後,按 F5 鍵運行它,隨後會彈出一個提示框,提醒您所選帳號中的所有類別已被清除,詳見截圖:

doc clear category 2