Using Classic Outlook on Windows for personal email, calendar, and contact management
Hi Klocke,
The Outlook desktop client can also display all folders, just click "Ctrl" + "6" to switch to Folder list view. Then you can find all the empty folders in Outlook and delete them if you don't need them any more. Press "Ctrl" + "1" will return Mail view.
And I prepare a VBA code for you to remove all empty subfolders of a certain Outlook folder, you can have a try to see if it work.
Please follow the steps below:
- Press Alt + F11 to open VBA window.
- Click Insert > Module, and paste below code into the new module window:
Public Sub DeletindEmtpyFolder()
Dim xFolders As Folders
Dim xCount As Long
Dim xFlag As Boolean
Set xFolders = Application.GetNamespace("MAPI").PickFolder.Folders
Do
FolderPurge xFolders, xFlag, xCount
Loop Until (Not xFlag)
If xCount > 0 Then
MsgBox "Deleted " & xCount & "(s) empty folders", vbExclamation + vbOKOnly, "Kutools for Outlook"
Else
MsgBox "No empty folders found", vbExclamation + vbOKOnly, "Kutools for Outlook"
End If
End Sub
Public Sub FolderPurge(xFolders, xFlag, xCount)
Dim I As Long
Dim xFldr As Folder 'Declare sub folder objects
xFlag = False
If xFolders.Count > 0 Then
For I = xFolders.Count To 1 Step -1
Set xFldr = xFolders.Item(I)
If xFldr.Items.Count < 1 Then 'If the folder is empty check for subfolders
If xFldr.Folders.Count < 1 Then 'If the folder contains not sub folders confirm deletion
xFldr.Delete 'Delete the folder
xFlag = True
xCount = xCount + 1
Else 'Folder contains sub folders so confirm deletion
FolderPurge xFldr.Folders, xFlag, xCount
End If
Else 'Folder contains items or (subfolders that may be empty).
FolderPurge xFldr.Folders, xFlag, xCount
End If
Next
End If
End Sub
- Click Run/F5, and select the target folder to run this VBA
- The empty folders should be deleted
Hope this can be helpful.
Best,
Shawn