Skip to main content

Outlook:如何刪除重複的日曆項目

Author: Sun Last Modified: 2025-05-12

有時候,當我們從其他裝置匯入活動時,會有一些重複的日曆項目。為了刪除這些重複的日曆項目,本教程介紹了兩種不同的方法,一種是在重複項較少時逐一手動刪除,另一種是使用VBA一次性刪除所有重複項。

手動逐個刪除重複的日曆項目

使用VBA一次性刪除重複的日曆項目


手動逐個刪除重複的日曆項目

 

要逐一手動刪除重複的日曆項目,您需要先按照特定順序列出它們,以便清楚地查看重複的項目,然後逐一刪除它們。

1. 通常情況下,日曆處於「日曆」檢視中,啟用您想要刪除重複項的日曆,然後點擊「檢視」>「變更檢視」>「清單」。

steps on manually removing duplicates calendar items one by one

現在,日曆已經以清單形式顯示。

steps on manually removing duplicates calendar items one by one
steps on manually removing duplicates calendar items one by one

2. 然後指定一個條件來比較項目是否重複,假設要比較項目是否有相同的主題。在日曆清單中點擊「主題」,這樣所有具有相同主題的項目都會被排列在一起。

steps on manually removing duplicates calendar items one by one

3. 現在,您可以通過右鍵點擊該項目並在彈出的上下文選單中選擇「刪除」來逐一刪除具有相同主題的項目。

steps on manually removing duplicates calendar items one by one

Outlook中的AI郵件助理:更聰明的回覆,更清晰的溝通(一鍵奇蹟!) 免費

使用Kutools for Outlook的AI郵件助理簡化您的日常Outlook任務。這個強大的工具會從您過去的郵件中學習,提供智能且準確的答覆,優化您的郵件內容,並幫助您輕鬆起草和潤色郵件。
doc ai email handle

此功能支援:

  • 智能回覆:根據您過去的對話獲得量身定制、精確且隨時可用的回覆。
  • 增強內容:自動優化您的郵件文字以提高清晰度和影響力。
  • 輕鬆撰寫:只需提供關鍵字,讓AI處理其餘部分,並有多種寫作風格可供選擇。
  • 智能擴展:通過上下文感知建議來拓展您的思路。
  • 摘要生成:即時獲取長郵件的簡潔概述。
  • 全球觸及:輕鬆將您的郵件翻譯成任何語言。

此功能支援:

  • 智能郵件回覆
  • 優化的內容
  • 基於關鍵字的草稿
  • 智能內容擴展
  • 郵件摘要生成
  • 多語言翻譯

最重要的是,此功能永遠完全免費不要再等待了——立即下載AI郵件助理並享受吧


使用VBA一次性刪除重複的日曆項目

 

這裡介紹一些可以在不同情況下刪除日曆文件夾中所有重複日曆項目的VBA程式碼。

1. 按下「Alt」 +「F11」 鍵以啟用「Microsoft Visual Basic for Applications」窗口。

2. 點擊「插入」>「模組」來創建一個新的空白模組,然後將以下程式碼複製並粘貼到模組中。

VBA:刪除某一特定類別中的所有重複日曆項目

'Sub RemoveDuplicateCalendar()
'UpdatebyExtendoffice20220413
  Dim xStores As Stores
  Dim xStore As Store
  Dim xRootFolder As Folder
  Dim xFolder As Object
  Set xStores = Application.Session.Stores
  For Each xStore In xStores
    Set xRootFolder = xStore.GetRootFolder
    For Each xFolder In xRootFolder.Folders
      Call ProcessFolders(xFolder)
    Next
  Next
  Set xStores = Nothing
End Sub

Sub ProcessFolders(ByVal CurrentFld As Folder)
  Dim xDictionary As Object
  Dim i As Long
  Dim xItem As Object
  Dim xKey As String
  Dim xSubFld As Folder
  On Error Resume Next
  If CurrentFld.DefaultItemType <> olAppointmentItem Then Exit Sub
  Set xDictionary = CreateObject("Scripting.Dictionary")
  For i = CurrentFld.Items.Count To 1 Step -1
    Set xItem = CurrentFld.Items.Item(i)
    'change categories as you need in below script
    If xItem.Categories = "date" Then
    'change the comparing items as you need
      xKey = xItem.Subject & xItem.Location & xItem.Body & xItem.Categories
      If xDictionary.Exists(xKey) = True Then
        xItem.Delete
      Else
        xDictionary.Add xKey, True
      End If
    End If
  Next i
  For Each xSubFld In CurrentFld.Folders
    ProcessFolders xSubFld
  Next
End Sub

在此VBA中,它將通過比較主題、地點、正文和類別來刪除「日期」這一類別中的所有重複項,您可以根據需要進行更改。

steps on using VBA to remove duplicates calendar items at once time

3. 然後按下「F5」 鍵或點擊運行來執行代碼,彈出「宏」對話框,選擇「RemoveDuplicateCalendar」並點擊「運行」。steps on using VBA to remove duplicates calendar items at once time .

steps on using VBA to remove duplicates calendar items at once time

然後「日期」類別中的重複項目已被刪除。

VBA:跨類別刪除所有重複的日曆項目

Sub RemoveDuplicateCalendar()
'UpdatebyExtendoffice20220413
  Dim xStores As Stores
  Dim xStore As Store
  Dim xRootFolder As Folder
  Dim xFolder As Object
  Set xStores = Application.Session.Stores
  For Each xStore In xStores
    Set xRootFolder = xStore.GetRootFolder
    For Each xFolder In xRootFolder.Folders
      Call ProcessFolders(xFolder)
    Next
  Next
  Set xStores = Nothing
End Sub

Sub ProcessFolders(ByVal CurrentFld As Folder)
  Dim xDictionary As Object
  Dim i As Long
  Dim xItem As Object
  Dim xKey As String
  Dim xSubFld As Folder
  On Error Resume Next
  If CurrentFld.DefaultItemType <> olAppointmentItem Then Exit Sub
  Set xDictionary = CreateObject("Scripting.Dictionary")
  For i = CurrentFld.Items.Count To 1 Step -1
    Set xItem = CurrentFld.Items.Item(i)
    'change the comparing items as you need
      xKey = xItem.Subject & xItem.Location & xItem.Body & xItem.Categories
      If xDictionary.Exists(xKey) = True Then
        xItem.Delete
      Else
        xDictionary.Add xKey, True
      End If
  Next i
  For Each xSubFld In CurrentFld.Folders
    ProcessFolders xSubFld
  Next
End Sub

運行此代碼後,每個類別中具有相同主題、地點、正文和類別的所有重複項都已刪除。

steps on using VBA to remove duplicates calendar items at once time
steps on using VBA to remove duplicates calendar items at once time

注意:上述VBA適用於包含子文件夾的日曆文件夾。