Solved

Expand Outlook 2007 Inbox folders when Opening Outlook

Posted on 2011-03-17
12
556 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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 18

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
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…

749 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