AutoFormatRules object (Outlook)

Represents the collection of AutoFormatRule objects in a view.

Remarks

Use the Add method or the Insert method of the AutoFormatRules collection to create a new formatting rule for the following objects derived from the View object:

AutoFormatRule objects contained in an AutoFormatRules collection are applied to each Outlook item in the order in which they are contained in the collection. Changes to AutoFormatRule objects are persisted only if the Save method of the AutoFormatRules collection is called.

Example

The following Visual Basic for Applications (VBA) example enumerates the AutoFormatRules collection for the current TableView object, disabling any custom formatting rule contained by the collection.

Private Sub DisableCustomAutoFormatRules() 
 
 Dim objTableView As TableView 
 
 Dim objRule As AutoFormatRule 
 
 
 
 ' Check if the current view is a table view. 
 
 If Application.ActiveExplorer.CurrentView.ViewType = olTableView Then 
 
 
 
 ' Obtain a TableView object reference to the current view. 
 
 Set objView = Application.ActiveExplorer.CurrentView 
 
 
 
 ' Enumerate the AutoFormatRules collection for 
 
 ' the table view, disabling any custom formatting 
 
 ' rule defined for the view. 
 
 For Each objRule In objView.AutoFormatRules 
 
 If Not objRule.Standard Then 
 
 objRule.Enabled = False 
 
 End If 
 
 Next 
 
 
 
 ' Save and apply the table view. 
 
 objView.Save 
 
 objView.Apply 
 
 End If 
 
End Sub 
 

Methods

Name
Add
Insert
Item
Remove
RemoveAll
Save

Properties

Name
Application
Class
Count
Parent
Session

See also

Outlook Object Model Reference

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.