• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

How do I replicate views through all my subfolders in my outlook personal folders

I am using Outlook 2003 and I have a personal folder with many sub-folders in it. I would like to replicate a new view that I have created to all the sub-folders. I have went through all the solutions in EE but none seems to work. Almost all of them suggest to go to the individual folders > view > arrange by > current view > and select "my_new_view". This is not a feasible idea as i got more than 100 sub folders and also sub-sub folders.

I saw a macro script posted by BlueDevilFan that can loop through the sub folders and change them to the new view. But the problem is that they script can only loop one level down, it won't go to the sub-sub-folders. I am looking for anyone that can come out with a new script that can do that. If you have any other solutions, please feel free to post here too. Thanks.

Sub ChangeCurrentView()
    Dim objExplorer As Outlook.Explorer, _
        objTempExplorer As Outlook.Explorer, _
        objFolder As Outlook.MAPIFolder, _
        strViewName As String
    strViewName = InputBox("What view would you like to change to?", "Change Current View")
    If strViewName <> "" Then
        Set objExplorer = Application.ActiveExplorer
        objExplorer.CurrentView = strViewName
        For Each objFolder In objExplorer.CurrentFolder.Folders
            Set objTempExplorer = Application.Explorers.Add(objFolder)
            objTempExplorer.CurrentView = strViewName
            objTempExplorer.Close
            Set objTempExplorer = Nothing
        Next
    End If
    Set objFolder = Nothing
    Set objExplorer = Nothing
End Sub
0
simonlai
Asked:
simonlai
  • 4
  • 3
1 Solution
 
David LeeCommented:
Hi simonlai,

Try this.  I haven't tested it, but it looks right.

Dim strViewName As String

Sub ChangeCurrentView()
    Const MACRO_NAME = "Change Current View"
    strViewName = InputBox("What view would you like to change to?", MACRO_NAME)
    If strViewName <> "" Then
        ChangeSubFolderView Application.ActiveExplorer.CurrentFolder
        MsgBox "All done!", vbInformation + vbOKOnly, MACRO_NAME
    Else
        MsgBox "Processing aborted.  No view entered.", vbInformation + vbOKOnly, MACRO_NAME
    End If
End Sub

Sub ChangeSubFolderView(objRootFolder As MAPIFolder)
    Dim objTempExplorer As Outlook.Explorer, _
        objFolder As Outlook.MAPIFolder
    Set objTempExplorer = Application.Explorers.Add(objFolder)
    objTempExplorer.CurrentView = strViewName
    objTempExplorer.Close
    Set objTempExplorer = Nothing
    For Each objFolder In objRootFolder.Folders
        ChangeSubFolderView objFolder
    Next
    Set objFolder = Nothing
End Sub

Cheers!
0
 
simonlaiAuthor Commented:
Hi BlueDevilFan,

Thanks for such fast reply, but the script doesn't seems to work. I receive the error message "could not complete the operation. one or more parameter value are not valid"

Hopefully you know whats wrong. cheers.
0
 
David LeeCommented:
simonlai,

I think I see the problem.  Change this line

    Set objTempExplorer = Application.Explorers.Add(objFolder)

to

    Set objTempExplorer = Application.Explorers.Add(objRootFolder)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
simonlaiAuthor Commented:
Hi BlueDevilFan,

i think it is still not working, when i run the macro, outlook shutdown by itself. upon launching outlook again, those sub folders does not change to the view as selected.
0
 
David LeeCommented:
Simon,

Sorry, I wasn't in a position to test earlier and was doing it off the top of my head.  I've tested the version below and it works properly.

Dim strViewName As String

Sub ChangeCurrentView()
    Const MACRO_NAME = "Change Current View"
    strViewName = InputBox("What view would you like to change to?", MACRO_NAME)
    If strViewName <> "" Then
        ChangeSubFolderView Application.ActiveExplorer.CurrentFolder
        MsgBox "All done!", vbInformation + vbOKOnly, MACRO_NAME
    Else
        MsgBox "Processing aborted.  No view entered.", vbInformation + vbOKOnly, MACRO_NAME
    End If
End Sub

Sub ChangeSubFolderView(objRootFolder As MAPIFolder)
    Dim objTempExplorer As Outlook.Explorer, _
        objFolder As Outlook.MAPIFolder
    Set objTempExplorer = Application.Explorers.Add(objRootFolder)
    objTempExplorer.CurrentView = strViewName
    Set objTempExplorer = Nothing
    For Each objFolder In objRootFolder.Folders
        ChangeSubFolderView objFolder
    Next
    Set objFolder = Nothing
End Sub

0
 
simonlaiAuthor Commented:
WOW!! you r a genius with VB script, to come out with something out of your head.. :) I presume u must be working as a programmer.

The script works very well, thanks a lot. I got to give it to you. Just a thought, why can't microsoft comes out with this function for Outlook after so many versions upgrades? I think many ppl would like to have this feature in their outlook.

I am also wondering why is it that a posting by yvsupport says that your initial script doesn't work, when it does.

http://www.experts-exchange.com/Applications/MS_Office/Outlook/Q_21505742.html?query=apply+view+to+all+existing+folder+in+outlook&clearTAFilter=true
0
 
David LeeCommented:
Thanks, Simon.  I'm not sure I'm a genius, but I appreciate the thought.  I do program some, although that's not primary job.  I don't know why Microsoft doesn't include certain features.  I also don't know why yvsupport said the initial script doesn't work.  
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now