Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Expand Outlook 2007 Inbox folders when Opening Outlook

Posted on 2011-03-17
12
Medium Priority
?
628 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
10 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 2000 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
Technology Partners: 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!

 

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

This article lists the top 5 trialware OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their Exchange server is no longer available or other critical issues with Exchange server or impo…
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
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 …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

824 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