Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change views in outlook 2003 2

Status
Not open for further replies.

AntunB

IS-IT--Management
Aug 11, 2003
263
AU
Hey,

can anyone tell me how to change the views for all folders in outlook 2003?
 
have you worked out how to do it from within VBA? i would advise opening up outlook and the visual basic editor and then using the object browser and searching for 'views'
once you have the code in VBA you can perhaps try and port it into vbscript, if you really need to run it from there

Using the Views collection
Use the Views property of the MAPIFolder object to return the Views collection. Use Views.Item(index),where index is the object's name or position within the collection, to return a single View object. The following example returns a View object of type olTableView called Table View. Before running this example, make sure a view by the name 'Table View' exists.

Sub GetView()
'Returns a view called Table View

Dim olApp As Outlook.Application
Dim objName As NameSpace
Dim objViews As Views
Dim objView As View

Set olApp = Outlook.Application
Set objName = olApp.GetNamespace("MAPI")
Set objViews = objName.GetDefaultFolder(olFolderInbox).Views
'Return a view called Table View
Set objView = objViews.Item("Table View")

End Sub


Use the Add method of the views collection to add a new view to the collection. The following example adds a new view of type olIconView in the user's Notes folder.

Note The Add method will fail if a view with the same name already exists.

Sub CreateView()
'Creates a new view

Dim olApp As Outlook.Application
Dim objName As NameSpace
Dim objViews As Views
Dim objNewView As View

Set olApp = Outlook.Application
Set objName = olApp.GetNamespace("MAPI")
Set objViews = objName.GetDefaultFolder(olFolderNotes).Views
Set objNewView = objViews.Add(Name:="New Icon View Type", _
ViewType:=olIconView, SaveOption:=olViewSaveOptionThisFolderEveryone)

End Sub

Use the Remove method to remove a view from the collection. The following example removes the above view, "New Icon View Type", from the collection.

Sub DeleteView()
'Deletes a view from the collection

Dim olApp As Outlook.Application
Dim objName As NameSpace
Dim objViews As Views
Dim objNewView As View

Set olApp = Outlook.Application
Set objName = olApp.GetNamespace("MAPI")
Set objViews = objName.GetDefaultFolder(olFolderNotes).Views
objViews.Remove ("New Icon View Type")

End Sub
 
thanks

but what its for is,

we are going to roll out office 2003, and want to have nice easy views


so only for it to run on first use, so how would i do that

thanks anyways, very helpful
 
is there something in the deploymetn wizard for office/outlook to configure views for you???

for only on first use i would suggest something that runs once at first logon
 
ok i have been playing around with some things, and it works, BUT it only works for the inbox folder and not all folders of the same type :(


code:
----------------------------------------------------------------
Sub NewView()
'Creates a new view and modifies its properties.
'Accepts 1 or 2 element names and their values.
'The second element and value are optional.

Dim objViews As Views
Dim objView As View
'Set a reference to the MSXML type library.
Dim objXML As New MSXML2.DOMDocument
Dim objXMLNode As MSXML2.IXMLDOMNode

Set objViews = Outlook.Application.GetNamespace(Type:="MAPI").GetDefaultFolder(FolderType:=olFolderInbox).Views
Set objView = objViews.Add(Name:="New View", ViewType:=olTableView, SaveOption:=olViewSaveOptionAllFoldersOfType)

'Load the schema into the MSXML parser.
objXML.loadXML bstrXML:=objView.XML

'Select the node you want to modify and assign a new value.
Set objXMLNode = objXML.selectSingleNode(querystring:="view/arrangement/autogroup")
objXMLNode.nodeTypedValue = "0"

'Check if optional input values exist; if so, change settings.
Set objXMLNode = objXML.selectSingleNode(querystring:="view/previewpane/visible")
objXMLNode.nodeTypedValue = "0"

'Copy the modified XML back to the new view.
objView.XML = objXML.XML
'Save and apply the new view.
objView.Save
objView.Apply

End Sub
----------------------------------------------------------------


how would i get it to work on all folders?
 
is it this line which is specific to the Inbox

Set objViews = Outlook.Application.GetNamespace(Type:="MAPI").GetDefaultFolder(FolderType:=olFolderInbox).Views

i.e. olFolderInbox

Perhaps you need to return a Folders collection and loop through it applying the view to all the folder?

 
noo i think that is the folder type

so if you have sub folders in the inbox its all the same type
 
AntunB, you might check out the Tech Republic article concerning the "/cleanviews" command line switch for Outlook 2003. The article is at the web link:


I'm not sure if it will solve your problem concerning Office rollout because the article mentions placing "/cleanviews" in the shortcut parameters for the Outlook shortcut. Additionally, their procedure requires about 13 or more steps.

The article has a link to another site about how to turn off the Reading Pane and Grouping (
Hope it helps and doesn't waste your time. ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top