Witzker
Senior Member
- OS Version(s)
- iOS
- Outlook version
- Outlook 2019 32-bit
- Email Account
- Exchange Server 2007
Hi Diane
I found your great macro to printout the folder structure of OL
Print a list of your Outlook folders (slipstick.com)
As I have 3 synct outlooks (SimpleSysn) and the tool is really good as time goes by with some errors shutdowns etc. there are sometimes a lot of duplicates in the different outlooks.
To go quickly through the different Ols your tool is very helpful.
BUT if it would be possible to sort the output of the folder list like it is displayed in OL It would be super PERFECT!
How is it possible to sort the output?
Top folder
Topfolder/- Axxxx
Topfolder/- Bxxxx
Topfolder/ Axxxx
Topfolder/ Bxxxx
Topfolder/ Bxxxx / -Axxx
Topfolder/ Bxxxx / Axxx
and so on
I use "-" before the NAME to get important Folders to be listed before the others beginning with A in alphabetic order as Outlook sorts the folders.
I hope you can have a look at the macro and help me.
I found your great macro to printout the folder structure of OL
Print a list of your Outlook folders (slipstick.com)
As I have 3 synct outlooks (SimpleSysn) and the tool is really good as time goes by with some errors shutdowns etc. there are sometimes a lot of duplicates in the different outlooks.
To go quickly through the different Ols your tool is very helpful.
BUT if it would be possible to sort the output of the folder list like it is displayed in OL It would be super PERFECT!
How is it possible to sort the output?
Top folder
Topfolder/- Axxxx
Topfolder/- Bxxxx
Topfolder/ Axxxx
Topfolder/ Bxxxx
Topfolder/ Bxxxx / -Axxx
Topfolder/ Bxxxx / Axxx
and so on
I use "-" before the NAME to get important Folders to be listed before the others beginning with A in alphabetic order as Outlook sorts the folders.
I hope you can have a look at the macro and help me.
Code:
Public strFolders As String
Public Sub GetFolderNames()
Dim olApp As Outlook.Application
Dim olSession As Outlook.NameSpace
Dim olStartFolder As Outlook.MAPIFolder
Dim lCountOfFound As Long
lCountOfFound = 0
Set olApp = New Outlook.Application
Set olSession = olApp.GetNamespace("MAPI")
' Allow the user to pick the folder in which to start the search.
Set olStartFolder = olSession.PickFolder
' Check to make sure user didn't cancel PickFolder dialog.
If Not (olStartFolder Is Nothing) Then
' Start the search process.
ProcessFolder olStartFolder
End If
' Create a new mail message with the folder list inserted
Set ListFolders = Application.CreateItem(olMailItem)
ListFolders.Body = strFolders
ListFolders.Display
' clear the string so you can run it on another folder
strFolders = ""
End Sub
Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder)
Dim i As Long
Dim olNewFolder As Outlook.MAPIFolder
Dim olTempFolder As Outlook.MAPIFolder
Dim olTempFolderPath As String
' Loop through the items in the current folder.
For i = CurrentFolder.Folders.Count To 1 Step -1
Set olTempFolder = CurrentFolder.Folders(i)
olTempFolderPath = olTempFolder.FolderPath
' Get the count of items in the folder
olCount = olTempFolder.Items.Count
'prints the folder path and name in the VB Editor's Immediate window
Debug.Print olTempFolderPath & " " & olCount
' prints the folder name only
' Debug.Print olTempFolder
' create a string with the folder names.
' use olTempFolder if you want foldernames only
strFolders = strFolders & vbCrLf & olTempFolderPath & " " & olCount
lCountOfFound = lCountOfFound + 1
Next
' Loop through and search each subfolder of the current folder.
For Each olNewFolder In CurrentFolder.Folders
'Don't need to process the Deleted Items folder
If olNewFolder.Name <> "Deleted Items" Then
ProcessFolder olNewFolder
End If
Next
End Sub
Last edited: