Thread: Set Custom View
View Single Post
  #3  
Old February 19th 09, 10:02 AM posted to microsoft.public.outlook.program_vba
Jeremy
external usenet poster
 
Posts: 28
Default Set Custom View

Hi.

I understand the principle but I can't code very well. Could you tell me
precisely the code?

If I could get the object I think I could code the apply and save method as
it's just object.apply & object.save (i think). Would you mind telling me the
line(s) of code that will give me / get me an object though, I tried:

Get Application.ActiveExplorer.CurrentView as a View object

and as I thought, that doesn't work!

Thanks - J



"Ken Slovak - [MVP - Outlook]" wrote:

You have to both Apply the setting and Save it.

Get Application.ActiveExplorer.CurrentView as a View object and then use the
View object Apply and then Save methods.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Jeremy" wrote in message
...
Hi,

I'm using Outlook 2007 and that version of VB.

I have an awful lot of folders and I wanted to set each to a particular
custom view. I have written the code below to go through each folder and
set
the custom view. However, it does not do this. I think I may need to
"save"
after Application.ActiveExplorer.CurrentView = "J VIEW" however, I do not
know how to do this and keep getting an object error. Could someone help.

(As you might realise I want to set the custom view for all folders. I
have
not found a macro to do this. I have tried cleaning the custom views using
"outlook.exe /cleanviews" and then changing the "messages" the default
view -
this does not work and in fact "outlook.exe /cleanviews" does not properly
reset the "messages" view - different folders have different views despite
being set to the "messages" view.)

My code (pieced together as I can't program):

Sub ProcessAllFolders()
ProcessSubFolder Application.ActiveExplorer.CurrentFolder
MsgBox "All Done!", vbInformation + vbOKOnly, "Process All Folders
Macro"
End Sub

Sub ProcessSubFolder(olkFolder As Outlook.MAPIFolder)
Dim olkSubFolder As Outlook.MAPIFolder


'Replace the following line with the code you want to run for each
folder
'Debug.Print olkFolder.FolderPath
Application.ActiveExplorer.CurrentView = "J VIEW"


For Each olkSubFolder In olkFolder.Folders
ProcessSubFolder olkSubFolder
Next
Set olkSubFolder = Nothing
End Sub





Ads