change default view to be NOT 'show in groups'

User avatar
stuck
Panoramic Lounger
Posts: 8127
Joined: 25 Jan 2010, 09:09
Location: retirement

change default view to be NOT 'show in groups'

Post by stuck »

Outlook 2007 hit our office today...

All my mailboxes are displayed in 'groups' like Date: Last Week and Date: Yesterday and Date: Today. At the moment I'm right clicking on the column headers and clicking 'Arrange By' and unticking 'Show in Groups' but that only applies to the mailbox I'm in and I have to do it again when I move to another mailbox. I have lots of mailboxes. Is there not a untick once / apply to all mailboxes option somewhere?

Ken

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: change default view to be NOT 'show in groups'

Post by HansV »

Best wishes,
Hans

User avatar
stuck
Panoramic Lounger
Posts: 8127
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: change default view to be NOT 'show in groups'

Post by stuck »

Thanks, not sure I'm brave enough (yet) to start messing with the registry. I think I'll have to wait a few days until the dust has settled a bit more and our IT people are more likely to forgive me if something goes wrong.

Ken

User avatar
Goshute
3StarLounger
Posts: 397
Joined: 24 Jan 2010, 19:43
Location: Salt Lake City, Utah, USA

Re: change default view to be NOT 'show in groups'

Post by Goshute »

EDITED - I overlooked that TWO functions AND a sub are called. Run the SetNoGroupViews sub.

You could give this code a whirl:

Code: Select all

Public colFolders As Collection

Public Function AllFoldersCollection(ByVal objRootFolder As MAPIFolder)
  Set colFolders = New Collection
  Call GetFoldersCollection(objRootFolder)
End Function

Private Function GetFoldersCollection(ByVal objStartFolder As MAPIFolder)
  Dim lngC As Long
  colFolders.Add Item:=objStartFolder, Key:="\" & objStartFolder.FolderPath
  For lngC = 1 To objStartFolder.Folders.Count
    colFolders.Add Item:=objStartFolder.Folders(lngC), _
        Key:=objStartFolder.Folders(lngC).FolderPath
    Debug.Print objStartFolder.Folders(lngC).FolderPath
    If objStartFolder.Folders(lngC).Folders.Count > 0 Then _
      Call GetFoldersCollection(objStartFolder.Folders(lngC))  'recurse this function to subfolders
  Next lngC
End Function

Sub SetNoGroupViews()
  Dim fldrSel As MAPIFolder
  Dim allSubFolders As New Collection
  Dim lngC As Long
  
  Set fldrSel = Application.GetNamespace("MAPI").PickFolder
  If Not fldrSel Is Nothing Then
    Call AllFoldersCollection(fldrSel)
    Set allSubFolders = colFolders
    For lngC = 1 To allSubFolders.Count
      If allSubFolders(lngC).DefaultItemType = olMailItem Then _
        Call SetTableProperties(allSubFolders(lngC), "Messages", "view/arrangement/autogroup", "0")
    Next lngC
  End If
  Set allSubFolders = Nothing
  Set fldrSel = Nothing
  MsgBox "Done"
End Sub

Sub SetTableProperties(ByRef fdrFolder As MAPIFolder, ByVal strViewName As String, _
                     ByVal strProp As String, ByVal strValue As String)
    'Jefferson Scher
    'Set a reference to the MSXML 2.6 type library.
    Dim objViews As Views
    Dim objView As View
    Dim objXML As New MSXML2.DOMDocument
    Dim objXMLNode As MSXML2.IXMLDOMNode
   
    Set objViews = fdrFolder.Views
    Set objView = objViews(strViewName)
    
    'Load the schema into the MSXML parser.
    objXML.loadXML bstrXML:=objView.XML
            
    'Select the node you want to modify and assign the new value.
    Set objXMLNode = objXML.selectSingleNode(querystring:=strProp)
    objXMLNode.nodeTypedValue = strValue
                  
    '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
You will need to run it on each information store (Exchange mailbox, other mailbox, each PST).

Acknowledging my use of Jefferson Scher's coding of the Outlook XML View Table Schema.
Last edited by Goshute on 02 Sep 2010, 15:59, edited 4 times in total.
Goshute
I float in liquid gardens

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: change default view to be NOT 'show in groups'

Post by StuartR »

Goshute wrote:...
You could give this code a whirl:
...
I just tried this on Outlook 2010 and, sadly, it doesn't work.
  • The variable colFolders is not defined
  • There doesn't seem to be a SetTableProperties function.
StuartR


User avatar
Goshute
3StarLounger
Posts: 397
Joined: 24 Jan 2010, 19:43
Location: Salt Lake City, Utah, USA

Re: change default view to be NOT 'show in groups'

Post by Goshute »

Oops, need to Type this public variable:

Public colFolders As Collection
Goshute
I float in liquid gardens

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: change default view to be NOT 'show in groups'

Post by StuartR »

Goshute wrote:Oops, need to Type this public variable:

Public colFolders As Collection
I guessed this one, but it still complains about SetTableProperties - Compile error: Sub or Function not defined.
StuartR


User avatar
Goshute
3StarLounger
Posts: 397
Joined: 24 Jan 2010, 19:43
Location: Salt Lake City, Utah, USA

Re: change default view to be NOT 'show in groups'

Post by Goshute »

Sorry - this is sufficiently old that I had forgotten which were called subs and procedures, and which were built in Outlook Methods. I have edited the earlier post to correct this.

In fact I'd be wary of using the code above, first run the code in this post. I'm not sure of the extent to which Outlook 2010 has revised the View table schema. Before running the revised code above, see if this runs first, and see if the schema still includes, among other things

Code: Select all

<view type="table">
  <viewname>Messages</viewname>
  ....
  <arrangement>
    <autogroup>0</autogroup>
  ...
Here's the code, examine the results in the Intermediates window:

Code: Select all

Sub GetTableViews()
  ' Jefferson Scher
  Dim objViews As Views
  Dim strViewName As String, strViewXML As String

  Set objViews = Application.GetNamespace("MAPI").PickFolder.Views
  strViewName = "Messages"
  strViewXML = objViews(strViewName).XML & vbLf & "- - - - - - - - - - - - - - - - - - - - - - - - - -"
  Debug.Print strViewXML

  Set objViews = Nothing
End Sub
Goshute
I float in liquid gardens

User avatar
Goshute
3StarLounger
Posts: 397
Joined: 24 Jan 2010, 19:43
Location: Salt Lake City, Utah, USA

Re: change default view to be NOT 'show in groups'

Post by Goshute »

By the way Stuart, you were one of the beneficiaries of this work in the distant past. :yep:
Goshute
I float in liquid gardens

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: change default view to be NOT 'show in groups'

Post by StuartR »

Goshute wrote:By the way Stuart, you were one of the beneficiaries of this work in the distant past. :yep:
I remember, and I want it back.

Thank you.
StuartR


User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: change default view to be NOT 'show in groups'

Post by StuartR »

When I run this code

Code: Select all

Sub GetTableViews()
  ' Jefferson Scher
  Dim objViews As Views
  Dim strViewName As String, strViewXML As String

  Set objViews = Application.GetNamespace("MAPI").PickFolder.Views
  strViewName = "Messages"
  strViewXML = objViews(strViewName).XML & vbLf & "- - - - - - - - - - - - - - - - - - - - - - - - - -"
  Debug.Print strViewXML

  Set objViews = Nothing
End Sub
I get the error "Object variable or With block variable not set" at the line
strViewXML = objViews(strViewName).XML & vbLf & "- - - - - - - - - - - - - - - - - - - - - - - - - -"
StuartR


User avatar
Goshute
3StarLounger
Posts: 397
Joined: 24 Jan 2010, 19:43
Location: Salt Lake City, Utah, USA

Re: change default view to be NOT 'show in groups'

Post by Goshute »

Sorry, Stuart, I will need help from someone using Outlook 2010 to go any further with this. (It still works in Outlook 2003 on XP.)
Goshute
I float in liquid gardens

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: change default view to be NOT 'show in groups'

Post by StuartR »

Reviving an ancient thread.

Does anyone have a method (VBA or otherwise) to clear the "Automatically group according to arrangement" flag for all Outlook views?

I tried getting this code to run, but there are too many changes for me to be able to get this going again.
StuartR


User avatar
Leif
Administrator
Posts: 7193
Joined: 15 Jan 2010, 22:52
Location: Middle of England

Re: change default view to be NOT 'show in groups'

Post by Leif »

Do you have different view settings for different folders? If not, does the Change View > Apply Current View to other folders... not do what you want?
Leif

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: change default view to be NOT 'show in groups'

Post by StuartR »

Thank you Leif, that worked perfectly. It did apply ALL view settings to every folder, which meant that I had to change a few things back - for example I wanted sent items to have a different view to other folders - but it was quick and simple.
StuartR