Reputation: 54
I am trying to set the Outlook Layout for all folders to Compact.
I managed to recursively loop through all the folders, but I cannot find any information on what I need to change the layout.
I compared the XML of a Single Line layout vs the Compact layout.
In Office 2019, I found the XML node to make this happen (<multiline></multiline>
) but in Office 365 the only difference I get when comparing both XML is the <previewstyle/>
.
When I remove this node and load it (and apply) to the XML for the current view, it doesn't set the layout to Compact.
How can this be done programmatically?
Upvotes: 0
Views: 308
Reputation: 54
Well, i removed the <showpreviewheader>0</showpreviewheader>
row and it did the job (tested in office 365 application)!
Thank you all for the time taken.
<previewpane>
<visible>1</visible>
<markasread>0</markasread>
<showpreviewheader>0</showpreviewheader> <<< removed this row
</previewpane>
Upvotes: 1
Reputation: 49455
You can do the required modifications in Outlook and then check out the XML markup of the current view in Outlook. So, you could be sure what changes are required. Here is what MSDN recommends when dealing with views in Outlook:
The CurrentView property returns a View object representing the current view. To properly reset the current view, you must do a View.Reset
and then a View.Apply
. The code sample below illustrates the order of the calls:
Sub ResetView()
Dim v as Outlook.View
' Save a reference to the current view object
Set v = Application.ActiveExplorer.CurrentView
' Reset and then apply the current view
v.Reset
v.Apply
End Sub
The View
object allows you to create customizable views that allow you to better sort, group and ultimately view data of all different types. There are a variety of different view types that provide the flexibility needed to create and maintain your important data.
Views are defined and customized using the View object's XML property. The XML
property allows you to create and set a customized XML schema that defines the various features of a view.
The XML definition describes the view type by using a series of tags and keywords corresponding to various properties of the view itself. When the view is created, the XML definition is parsed to render the settings for the new view.
To determine how the XML should be structured when creating views, you can create a view by using the Outlook user interface and then you can retrieve the XML property for that view.
To programmatically add a custom field to a view, use the Add method of the ViewFields object. This is the recommended way to dynamically change the view over setting the XML
property of the View
object.
Upvotes: 0