How to export folder structure from Outlook to Excel?
This article, I will introduce how to export folder structure of an account from Outlook to Excel file. Please achieve it with the details of this article.
Export folder structure of an account from Outlook to Excel by using VBA code
Export folder structure of an account from Outlook to Excel by using VBA code
The following VBA code may do you a favor, please do with below steps:
1. Enable Excel and hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Export folder structure of an account from Outlook to Excel:
Dim xExcelApp As Excel.Application
Dim xWb As Excel.Workbook
Dim xWs As Excel.Worksheet
Dim xMainFolderCount As Long
Sub OutlookExportFolderStructureToExcel()
Dim xFolder As Folder
Dim xExcelFile As String
Dim xFileDialog As FileDialog
On Error Resume Next
Set xFolder = Outlook.Application.Session.PickFolder
If xFolder Is Nothing Then Exit Sub
Set xExcelApp = New Excel.Application
Set xWb = xExcelApp.Workbooks.Add
Set xWs = xWb.Sheets(1)
With xWs.Range("A1", "A1")
.Value = "Folder Structure"
.Font.Size = 14
.Font.Bold = True
End With
xMainFolderCount = Len(xFolder.FolderPath) - Len(Replace(xFolder.FolderPath, "\", "")) + 1
Call ExportToExcel(xFolder.FolderPath, xFolder.Name)
Call ProcessFolders(xFolder.Folders)
xWs.Columns("A").AutoFit
Set xFileDialog = xExcelApp.FileDialog(msoFileDialogSaveAs)
With xFileDialog
.AllowMultiSelect = False
.FilterIndex = 1
If .Show = 0 Then
xWb.Close False
xExcelApp.Quit
Set xExcelApp = Nothing
Exit Sub
End If
xExcelFile = .SelectedItems.Item(1)
End With
xWb.Close True, xExcelFile
MsgBox "Export complete!", vbExclamation, "Kutools for Outlook"
End Sub
Sub ProcessFolders(ByVal xFlds As Folders)
Dim xSubFolder As Folder
For Each xSubFolder In xFlds
If xSubFolder.Name <> "Conversation Action Settings" And xSubFolder.Name <> "Quick Step Settings" Then
Call ExportToExcel(xSubFolder.FolderPath, xSubFolder.Name)
Call ProcessFolders(xSubFolder.Folders)
End If
Next
End Sub
Sub ExportToExcel(ByRef xFolderPath As String, xFolderName As String)
Dim i, n As Long
Dim xPrefix As String
Dim xLastRow As Integer
i = Len(xFolderPath) - Len(Replace(xFolderPath, "\", "")) - xMainFolderCount
For n = 0 To i
xPrefix = xPrefix & "-"
Next
xFolderName = xPrefix & xFolderName
xLastRow = xWs.UsedRange.Rows.Count + 1
xWs.Range("A" & xLastRow) = xFolderName
End Sub
3. Still in the Microsoft Visual Basic for Applications window, click Tools > References to go to the References-Project1 dialog box, and check Microsoft Excel Object Library option from the Available References list box, see screenshot:

4. Then click OK button, and press F5 key to run this code, a Select Folder dialog box is popped out, please select the email account that you want to export its folder structure, see screenshot:

5. And then, click OK button, a File Save window is displayed, please specify a location and file name for this exported file, see screenshot:

6. At last, click Save button, and you can go to the specific excel workbook you have saved to view the exported folder structure, see screenshot:

Best Office Productivity Tools
Breaking News: Kutools for Outlook Launches Free Version!
Experience the all-new Kutools for Outlook with 100+ incredible features! Click to download now!
π€ Kutools AI : Uses advanced AI technology to handle emails effortlessly, including replying, summarizing, optimizing, extending, translating, and composing emails.
π§ Email Automation: Auto Reply (Available for POP and IMAP) / Schedule Send Emails / Auto CC/BCC by Rules When Sending Email / Auto Forward (Advanced Rules) / Auto Add Greeting / Automatically Split Multi-Recipient Emails into Individual Messages ...
π¨ Email Management: Recall Emails / Block Scam Emails by Subjects and Others / Delete Duplicate Emails / Advanced Search / Consolidate Folders ...
π Attachments Pro: Batch Save / Batch Detach / Batch Compress / Auto Save / Auto Detach / Auto Compress ...
π Interface Magic: πMore Pretty and Cool Emojis / Remind you when important emails come / Minimize Outlook Instead of Closing ...
π One-click Wonders: Reply All with Attachments / Anti-Phishing Emails / πShow Sender's Time Zone ...
π©πΌβπ€βπ©π» Contacts & Calendar: Batch Add Contacts From Selected Emails / Split a Contact Group to Individual Groups / Remove Birthday Reminders ...
Use Kutools in your preferred language β supports English, Spanish, German, French, Chinese, and 40+ others!


π One-Click Download β Get All Office Add-ins
Strongly Recommended: Kutools for Office (5-in-1)
One click to download five installers at once β Kutools for Excel, Outlook, Word, PowerPoint and Office Tab Pro. Click to download now!
- β One-click convenience: Download all five setup packages in a single action.
- π Ready for any Office task: Install the add-ins you need, when you need them.
- π§° Included: Kutools for Excel / Kutools for Outlook / Kutools for Word / Office Tab Pro / Kutools for PowerPoint