Solved

Expand Outlook 2007 Inbox folders when Opening Outlook

Posted on 2011-03-17
12
505 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Use email signature images to promote corporate certifications and industry awards.
Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now