Thread: [Solved] Customize Current View
View Single Post
 
Old 04-12-2013, 04:20 AM
niton niton is offline Windows 7 64bit Office 2010 64bit
Competent Performer
 
Join Date: Jul 2012
Posts: 102
niton is on a distinguished road
Default

Quote:
Originally Posted by rossmoyne View Post
Niton,

This is a good start, but it doesn't seem to finish, with how to apply to all my folders.
It doesn't say what to do, what to modify once you get to the "Custom View Oranizer" And how to apply your new template to all the subfolders.

Also, I have multiple PST folders, would I have to do this to each one? (Which is not a problem)

Thanks.
As indicated, the link provided info for folders yet to be created in Outlook 2007. The option of applying the view to already created folders is available in Outlook 2010.

If you wish, you can try this.

First verify the name of the view in this line ActiveExplorer.CurrentView = "Messages". If you find you have to change "Messages" leave the quotes in.

Select a folder then run the code.

Check it out on a test folder with subfolders before you try the inbox.

Code:
Sub Set_View()

    Dim objNS As Outlook.Namespace
    Dim myFolder As Outlook.MAPIFolder
    Dim origFolder As Outlook.MAPIFolder

    Set objNS = Application.GetNamespace("MAPI")
    Set origFolder = ActiveExplorer.CurrentFolder
    Set myFolder = origFolder

    ProcessFolder myFolder

    Set ActiveExplorer.CurrentFolder = origFolder

    Set objNS = Nothing
    Set myFolder = Nothing
    Set origFolder = Nothing

End Sub


Private Sub ProcessFolder(startfolder As Outlook.MAPIFolder)

' http://www.outlookcode.com/codedetail.aspx?id=628

    Dim objFolder As Outlook.MAPIFolder
    Dim objItem As Object
    Dim myExplorer As Explorer
       
    Set ActiveExplorer.CurrentFolder = startfolder   

    ActiveExplorer.CurrentView = "Messages"

    ' process all the subfolders of this folder
    For Each objFolder In startfolder.Folders
        ProcessFolder objFolder
    Next

End Sub
If you are unfamiliar with VBA see here http://www.slipstick.com/developer/h...ks-vba-editor/

You will find information about:
- macro security settings
- where to put the code (You can use a regular module with Insert | Module)
- how to create a button
Reply With Quote