[FONT=Fixedsys]Option Explicit[/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys]Dim ws As Worksheet
Dim iRow As Integer
Const bTitles As Boolean = True [COLOR=green]' do we want column titles?[/COLOR][/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys]Public Sub ListFolders()[/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys] Dim objNS As Outlook.Namespace
Set ws = ThisWorkbook.Sheets("Sheet1")
Set objNS = Outlook.Application.GetNamespace("MAPI")
ws.UsedRange.ClearContents
iRow = IIf(bTitles, 1, 0)
If bTitles Then ws.Range("A1:D1") = Array("Folder Path & Name", "Items", "", "Indented List Of Folders")
ws.Range("A1:D1").Font.Bold = bTitles
ListFromFolder objNS, 1, ""
ws.Cells(iRow + 1, 2) = "=SUM(B" & IIf(bTitles, "2", "1") & ":B" & CStr(iRow) & ")"
ws.UsedRange.ColumnWidth = 4
ws.Columns("A:B").AutoFit
MsgBox "Done:-" & vbCrLf & vbCrLf _
& CStr(iRow - IIf(bTitles, 1, 0)) & " folders listed" & Space(15) & vbCrLf & vbCrLf _
& Format(ws.Cells(iRow + 1, 2), "#,##0") & " items counted", _
vbOKOnly + vbInformation
Set objNS = Nothing
Set ws = Nothing
End Sub[/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys]Private Sub ListFromFolder(objFolderRoot As Object, argLevel As Integer, argFullName As String)[/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys] Dim objFolder As MAPIFolder
For Each objFolder In objFolderRoot.Folders
DoEvents
iRow = iRow + 1
' full folder path in column A
ws.Cells(iRow, 1) = argFullName & "\" & objFolder.Name
' count of items in folder in column B
On Error Resume Next
ws.Cells(iRow, 2) = objFolder.Items.Count
On Error GoTo 0
' indented folder list in column C onwards
ws.Cells(iRow, argLevel + 3) = objFolder.Name
If objFolder.Folders.Count > 0 Then
ListFromFolder objFolder, argLevel + 1, argFullName & "\" & objFolder.Name[/FONT]
[FONT=Fixedsys] End If
Next objFolder
Set objFolder = Nothing[/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys]End Sub[/FONT]