How to Batch Delete All Empty Calendar Groups in Your Outlook

Aside from the default calendar group “My Calendars” in the Calendar navigation pane, you can also create custom calendar groups at will. Now, if you’d like to batch delete all empty calendar groups, you can use the way shared in this post.

To better manage multiple calendars in your Outlook, you can spread them into different calendar groups. The default calendar group is called as “My Calendars”. Apart from it, you can customize the others to your likings. In reality, many users have created several custom calendar groups and move some calendars to these groups. Over time, it’s possible that some calendar groups are empty without any calendars. In this situation, users wish to bulk delete all empty calendar groups. Now, thereinafter, we will introduce a quick way to realize it.

Batch Delete All Empty Calendar Groups

  1. At the very outset, launch Outlook program.
  2. Then, get access to Outlook VBA editor according to “How to Run VBA Code in Your Outlook“.
  3. After that, put the following code into an unused module or project.
Sub BatchDeleteAllEmptyCalendarGroups()
    Dim objNavigationPane As Outlook.NavigationPane
    Dim objCalendarModule As Outlook.CalendarModule
    Dim objCalendarGroups As Outlook.NavigationGroups
    Dim i As Integer
    Dim objCalendarGroup As Outlook.NavigationGroup
    Dim objCalendarFolders As Outlook.NavigationFolders
 
    'Get the calendar groups in Calendar navigation module
    Set objNavigationPane = Application.ActiveExplorer.NavigationPane
    Set objCalendarModule = objNavigationPane.Modules.GetNavigationModule(olModuleCalendar)
    Set objCalendarGroups = objCalendarModule.NavigationGroups

    If objCalendarGroups.Count = 1 Then
       MsgBox "There is only a calendar group!", vbInformation + vbOKOnly
       'If there is more than one calendar group
    ElseIf objCalendarGroups.Count > 1 Then
       For i = objCalendarGroups.Count To 1 Step -1
           Set objCalendarGroup = objCalendarGroups.Item(i)
 
           'If the calendar group is not the default one
           If objCalendarGroup.GroupType = olCustomFoldersGroup Then
              Set objCalendarFolders = objCalendarGroup.NavigationFolders
 
              If objCalendarFolders.Count > 0 Then
                 Exit Sub
                 'If there is not folder in the calendar group
              Else
                 'Delete the calendar group
                 objCalendarGroups.Delete objCalendarGroup
              End If
           End If
       Next
    End If
End Sub

VBA Code - Batch Delete All Empty Calendar Groups

  1. After that, directly tap on “F5” key button.
  2. When macro finishes, go back to the Calendar navigation pane.
  3. You will see that all the empty calendar groups have been deleted, as shown in the following figure.Empty Calendar Groups Are Deleted

What Results in Outlook Corruption

Outlook file is easy to be corrupt. In face of such a knotty problem, it is necessary to make clear about the possible causes. As a matter of fact, multiple factors can lead to it, ranging from human errors, virus infection, power outages to hardware faults, etc. But, regardless of the real causes, the only solution is to fix PST. It can be undertaken by the unbuilt tool – Scanpst, or a more experienced external tool, like DataNumen Outlook Repair or a specialized third party recovery service.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupt mdf and outlook repair software products. For more information visit www.datanumen.com

Leave a Reply

Your email address will not be published. Required fields are marked *