Solved

Expand Outlook 2007 Inbox folders when Opening Outlook

Posted on 2011-03-17
12
547 Views
Last Modified: 2013-02-09
Hello,

we have a user that has many folders in his Inbox. We are using Outlook 2007, Imap. We switched from POP.

Basically, the folders upon restarting outlook, doesn't remain expanded after you reopen Outlook.All of The Inbox folders are collapsed.

Is there a way to have all the Folders in the Inbox expanded via Script/VBA or is there is setting that will allow the Expansion of the Inbox folders to retain through a restart.

0
Comment
Question by:Atomicsteaks
  • 6
  • 3
12 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 35163187
I'm not aware you can change the default behaviour but a macro to open all folders is viable as below

expandAll will expand all the default folders, expandInbox will only expand the inbox.

Chris
Sub expandAll()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim MyFolder As Outlook.MAPIFolder
Dim arrControl As Long
Dim strStoresItem As Variant

    On Error Resume Next
    
    Set olApp = Outlook.Application
    Set objNS = olApp.GetNamespace("MAPI")
    For Each strStoresItem In Application.Session.Stores
        If Not strStoresItem.ExchangeStoreType = olExchangePublicFolder Then
            Set MyFolder = objNS.GetFolderFromID(strStoresItem.StoreID)
            pf_expandAll MyFolder
        End If
    Next

Set objNS = Nothing
Set olApp = Nothing
Set MyFolder = Nothing
 
End Sub
Sub expandInbox()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim MyFolder As Outlook.MAPIFolder
Dim arrControl As Long
Dim strStoresItem As Variant

    On Error Resume Next
    
    Set olApp = Outlook.Application
    Set objNS = olApp.GetNamespace("MAPI")
    Set MyFolder = objNS.Session.GetDefaultFolder(olFolderInbox)
    pf_expandAll MyFolder

Set objNS = Nothing
Set olApp = Nothing
Set MyFolder = Nothing
 
End Sub

Sub pf_expandAll(startFolder As MAPIFolder)
Dim fldr As Outlook.MAPIFolder
Dim objitem As Object
Dim mai As MailItem
    On Error Resume Next
    
    ' process all the subfolders of this folder
    If startFolder.DefaultItemType <> olMailItem Then Exit Sub
    Set Application.ActiveExplorer.CurrentFolder = startFolder
    DoEvents
    For Each fldr In startFolder.folders
        Call pf_expandAll(fldr)
    Next
 
Set mai = Nothing
Set fldr = Nothing
End Sub

Open in new window

0
 

Author Comment

by:Atomicsteaks
ID: 35168752
Great!!!..Will try It out Over the weekend. Never Added a Marco To Outlook-Will review that First than go from There...
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35168822
To Create a macro:
------------------

Alt + F11 to open the macro editor

  For User Code:
     Insert | Module to insert a code module into the project
     In the project tree select the module.
     Insert the required macro(s) into the selected module, ('Module1' or similar)

Close the Visual Basic Editor.

To run a macro:
---------------

Alt + F8
Select the macro
Select 'Run'
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:Atomicsteaks
ID: 35202196
Issue running the macro's..

“The macros in this project are disabled. Please refer to the online help or documentationof the host application to determine how to enable macros.”

Even though My security is set to the lowest option...Within outlook...
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35202256
Have you re-opened outlook since enabling macros

Chris
0
 

Author Comment

by:Atomicsteaks
ID: 35749989
Yes,

Program still errors out..
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35750035
Virus application enabled?

Chris
0
 
LVL 17

Expert Comment

by:Karen Falandays
ID: 38869609
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 38869603
I have posted a solution for the issue and maintained communications including checking why the macros are not running.  There is a therefore a perfectly viable solution here that should be accepted.

35163187

Chris
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 38869610
oops!

I have posted a solution for the issue and maintained communications including checking why the macros are not running.  There is a therefore a perfectly viable solution here that should be accepted.

35163187

Chris
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question