I have this routine that works in outlook 2010 but not in outlook 2013 (365).
`

Public Sub readTextFile(oFolder As eFolder)
    If oFolder = NotSupported Then Exit Sub
    If oFolder = Inbox Then
        ActiveExplorer.CurrentView = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Views("MgInbox")
    Else
        ActiveExplorer.CurrentView = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Views("MgSentMail")
    End If
    Dim oTV As Outlook.TableView
    Set oTV = ActiveExplorer.CurrentView
    <b> oTV.AutoFormatRules.item(eColor.Green).Filter = cGetFilter(oFolder, Green) </b>
    oTV.AutoFormatRules.item(eColor.Red).Filter = cGetFilter(oFolder, Red)
    oTV.AutoFormatRules.item(eColor.Brown).Filter = cGetFilter(oFolder, Brown)
    oTV.AutoFormatRules.item(eColor.Blue).Filter = cGetFilter(oFolder, Blue)
    oTV.Apply
End Sub

AtoTV.AutoFormatRules.item(eColor.Green).Filter = cGetFilter(oFolder, Green) it tells me that I have insufficient rights on the folder. (error 86204005, You don't have appropriate permission to perform this operation)

Dani AI

Generated

’s diagnosis is correct: the error happens because the rule being targeted is a built‑in (standard) AutoFormatRule and Outlook does not allow changing its Filter or Name. Built‑in rules report Standard = True, and an attempt to assign Filter on such a rule raises an error. (learn.microsoft.com)

A reliable pattern is to detect whether a rule is standard and only modify non‑standard rules; if the built‑in rule is present, create a custom rule instead. The example below shows the approach (replace the placeholder DASL string with the actual filter generator used in the thread):

Dim tv As Outlook.TableView
Dim r As Outlook.AutoFormatRule
Dim custom As Outlook.AutoFormatRule
Dim filterStr As String

filterStr = "<DASL filter string for Green items>"

Set tv = Application.ActiveExplorer.CurrentView

For Each r In tv.AutoFormatRules
  If LCase(r.Name) = "green - custom" Then
    If Not r.Standard Then
      r.Filter = filterStr
      r.Enabled = True
      tv.Save
      tv.Apply
      Exit Sub
    End If
  End If
Next

Set custom = tv.AutoFormatRules.Add("Green - custom")
custom.Filter = filterStr
custom.Enabled = True
tv.Save
tv.Apply

Create and name custom rules with unique names (for example append “- custom”) so the code can find and update them later. Changes to AutoFormatRule objects are persisted only after saving/applying the view, so call Save and Apply after edits. (learn.microsoft.com)

Also confirm the current view is a TableView (AutoFormatRules applies to table-style views) and avoid attempting to remove or alter built‑in rules — they cannot be deleted or re-ordered by code. This behavior is why creating editable custom rules at runtime is the safest approach for Outlook 2013+. (learn.microsoft.com)

It seems that the standard property of the AutoformatRules were set to true. I solved the problem by getting rid of them and creating them on the fly, which if I'm right you could not do in 2010. The documentation is particularily cryptic on this subject.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.