On Tuesday, I got tired of navigating the bowels of Outlook's menu system just to briefly turn grouping off and on. Grouping is a new, nifty feature in Outlook 2003.
So I wrote the following code to toggle grouping, and I customized my toolbar to add a button that invokes it. The code uses the XML property of the View object. The XML property is very cool. It looks like I can do a lot with it.
Sub ToggleGrouping() ' (c) 2005 Luddite Geek
' Provide a way to toggle item grouping.
' 06/28/05 Created.
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlView As View
Dim strView As String
Dim i As Integer, j As Integer, n As Integer
Set myOlExp = myOlApp.ActiveExplorer
Set myOlView = myOlExp.CurrentView
strView = myOlView.XML
i = InStr(1, strView, "<arrangement>")
j = InStr(i, strView, "<autogroup>")
i = j + Len("<autogroup>")
n = CInt(Mid(strView, i, 1))
If n = 0 Then
Mid(strView, i, 1) = 1
ElseIf n = 1 Then
Mid(strView, i, 1) = 0
myOlView.XML = strView
The code on this page is provided free of charge. The author assumes no liability for any undesired effects it might have. Users may freely distribute the code only if this disclaimer is included. Users may not claim the work as their own.