![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]()
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 |
#4
|
|||
|
|||
![]()
Dim oView As Outlook.View
Set oView = Application.ActiveExplorer.CurrentView ' other code oView.Apply oView.Save -- 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 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 |
#5
|
|||
|
|||
![]()
I tried all these methods without success and I decided to go the hard way
about it but it works just like I want it. Here is what I did: 1. Configure the view they way I want it (fields, formating, etc.) 2. Run a script to extract the XML settings from the current view and save it to a file 3. Use a form to list all current forms and add a new view of my own 4. If I select my custom view from the list, I update its XML property with the xml settings from step 2, save it and then apply it to the current explorer. 5. Done. I have my view with all the fields I need and if I need to modify it, I can always update the text file containing my xml code. Here is the code to extract the XML setting: Dim myOLapp1 As Outlook.Application = Globals.ThisAddIn.Application Dim myExpl As Outlook.Explorer = myOLapp1.ActiveExplorer Dim myView1 As TableView = myExpl.CurrentView Dim myfol As Outlook.MAPIFolder = myExpl.CurrentFolder Dim myfields As ViewFields = myView1.ViewFields 'Dim myxmlItem As ViewField Dim file As System.IO.StreamWriter file = My.Computer.FileSystem.OpenTextFileWriter("C:\View XMLSettings.txt", False) If myfol.DefaultItemType = OlItemType.olContactItem Then file.WriteLine(myView1.XML) file.Close() End If myOLapp1 = Nothing myExpl = Nothing myfol = Nothing |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Folder Custom View | Naji | Add-ins for Outlook | 6 | April 24th 08 02:44 AM |
Custom View | Alphagmale | Outlook - General Queries | 0 | November 26th 07 04:04 PM |
Custom view is not working | Dhananjay | Outlook and VBA | 3 | October 15th 07 04:24 PM |
Need help creating a custom view in appointment view | Jack B. Pollack | Outlook - General Queries | 6 | June 15th 07 04:48 PM |
(Private View) in Custom View Organizer in OL 03 | Bob S | Outlook - General Queries | 3 | July 5th 06 12:34 AM |