0

How would I write a macro to set all folder properties to "see all items"? I have hundreds of folders and subfolders and need to set the folders to see all items and I can't figure out how to write a macro. Finally decided I needed some assistance. This should be a setting in outlook similar to default archive settings.

1
  • Have you tried anything yet? Are you stuck on something specific?
    – Dave M
    Nov 10, 2013 at 21:20

2 Answers 2

0

Your request to teach you to write a macro may be too general. So instead here is an answer for how to expand all folders.

http://www.msoutlook.info/question/595 and
http://vboffice.net/sample.html?lang=en&mnu=2&smp=57&cmd=showitem

You may decide to expand all folders when needed not necessarily on startup.

"This sample opens all the tree at startup, and it's a spectacle...

There's a variable 'ExpandDefaultStoreOnly' in the procedure 'ExpandAllFolders'. With the current value (True) only the Personal Folder gets expanded. If you want to expand all available mailboxes (archives, Exchange) then set the variable = False."

http://vboffice.net/sample.html?lang=en&mnu=2&smp=57&cmd=showitem

Private Sub Application_Startup()
    ExpandAllFolders
End Sub

Private Sub ExpandAllFolders()
On Error Resume Next
Dim Ns As Outlook.NameSpace
Dim Folders As Outlook.Folders
Dim CurrF As Outlook.MAPIFolder
Dim F As Outlook.MAPIFolder
Dim ExpandDefaultStoreOnly As Boolean

ExpandDefaultStoreOnly = True

Set Ns = Application.GetNamespace("Mapi")
Set CurrF = Application.ActiveExplorer.CurrentFolder

If ExpandDefaultStoreOnly = True Then
    Set F = Ns.GetDefaultFolder(olFolderInbox)
    Set F = F.Parent
    Set Folders = F.Folders
    LoopFolders Folders, True

Else
    LoopFolders Ns.Folders, True
End If

DoEvents
Set Application.ActiveExplorer.CurrentFolder = CurrF
End Sub

Private Sub LoopFolders(Folders As Outlook.Folders, _
    ByVal bRecursive As Boolean)

Dim F As Outlook.MAPIFolder

For Each F In Folders
    Set Application.ActiveExplorer.CurrentFolder = F
    DoEvents

    If bRecursive Then
        If F.Folders.Count Then
            LoopFolders F.Folders, bRecursive
      End If
    End If
Next
End Sub
1
  • This is not what he needs.
    – thims
    Nov 11, 2013 at 16:51
0

The following script will set all subfolders of your Inbox in the Default store to show total item count:

Private Sub ShowTotalCount(Folders As Folders)
    For Each Folder In Folders
        Folder.ShowItemCount = olShowTotalItemCount
        ShowTotalCount Folder.Folders
    Next
End Sub

Sub ShowTotalCountAll()
    ShowTotalCount Session.DefaultStore.GetDefaultFolder(olFolderInbox).Folders
End Sub

Just paste it to ThisOutlookSession in Outlook VBA (press ALT+F11 to open it). After that run ShowTotalCountAll macro by pressing F5.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .