共用方式為


AutoFormatRules Object (Outlook)

Represents the collection of AutoFormatRule objects in a view.

Version Information

Version Added: Outlook 2007

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 
 

See Also

Concepts

AutoFormatRules Object Members

Outlook Object Model Reference