跳到主要內容

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

作者:孫 最後修改時間:2022-04-29

有時,當我們從其他設備導入事件時,會有一些重複的日曆項目。 為了去除重複的日曆項,本教程介紹了兩種不同的方法,一種是在重複項較少時逐個刪除,另一種是使用VBA一次刪除所有重複項。

手動刪除重複的日曆項

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

Office 標籤 - 在 Microsoft Office 中啟用選項卡式編輯和瀏覽,讓工作變得輕而易舉
Kutools for Outlook - 透過 100 多個進階功能增強 Outlook,實現卓越效率
使用這些進階功能增強您的 Outlook 2021 - 2010 或 Outlook 365。 享受全面的 60 天免費試用並提升您的電子郵件體驗!

手動刪除重複的日曆項

 

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

1.一般來說,日曆是在一個 日曆 查看,激活要刪除重複項的日曆,然後單擊 瀏覽 > 更改視圖 > 名單.

doc 刪除重複的日曆項目 1

現在日曆已被視為列表。

doc 刪除重複的日曆項目 1

doc 刪除重複的日曆項目 1

2. 然後指定用於比較項目是否重複的條件,假設比較項目是否具有相同的主題。 點擊 學科 在日曆列表中,然後將具有相同主題的所有項目放在一起。

doc 刪除重複的日曆項目 1

3. 現在您可以通過右鍵單擊項目並單擊來將具有相同主題的項目一一刪除 刪除 從彈出的上下文菜單中。

doc 刪除重複的日曆項目 1


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

 

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

1。 按 其他 + 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 中,它將刪除“日期” 這個類別通過比較主題、位置、正文和類別,您可以根據需要進行更改。

doc 刪除重複的日曆項目 1

3.然後按 F5 鍵或單擊 Run 運行代碼,出現對話框 彈出,選擇 刪除重複日曆 並點擊 跑 doc 刪除重複的日曆項目 1 .

doc 刪除重複的日曆項目 1

然後刪除了“日期”類別中的重複項。

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

運行此代碼,每個類別中相同主題、位置、正文、類別的所有重複項均已刪除。

doc 刪除重複的日曆項目 1

doc 刪除重複的日曆項目 1

備註:以上 VBA 作品在日曆文件夾中包括子文件夾。


最佳辦公生產力工具

Kutools for Outlook - 超過 100 種強大的功能可增強您的 Outlook

🤖 人工智慧郵件助手: 具備人工智慧魔力的即時專業電子郵件——一鍵天才回覆、完美語調、多語言掌握。輕鬆改變電子郵件! ……

📧 電子郵件自動化: 外出(適用於 POP 和 IMAP)  /  安排發送電子郵件  /  發送電子郵件時按規則自動抄送/密件副本  /  自動轉送(進階規則)   /  自動添加問候語   /  自動將多收件者電子郵件拆分為單獨的訊息 ...

📨 電子郵件管理: 輕鬆回憶電子郵件  /  按主題和其他人阻止詐騙電子郵件  /  刪除重複的電子郵件  /  進階搜索  /  合併資料夾 ...

📁 附件專業版批量保存  /  批量分離  /  批量壓縮  /  自動保存   /  自動分離  /  自動壓縮 ...

🌟 介面魔法: 😊更多又漂亮又酷的表情符號   /  使用選項卡式視圖提高 Outlook 工作效率  /  最小化 Outlook 而不是關閉 ...

👍 一鍵奇蹟: 使用傳入附件回覆全部  /   反網路釣魚電子郵件  /  🕘顯示寄件者的時區 ...

👩🏼‍🤝‍👩🏻 通訊錄和行事曆: 從選定的電子郵件中大量新增聯絡人  /  將聯絡人群組拆分為各組  /  刪除生日提醒 ...

超過 100特點 等待您的探索! 按此處了解更多。

了解更多       免費下載      購買
 

 

Comments (2)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Sadly neither of these work
This comment was minimized by the moderator on the site
I have tested the code and both of them work, What is your problem?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations