Class AutoFormatRules (Outlook VBA)

The class AutoFormatRules represents the collection of AutoFormatRule objects in a view. To use a AutoFormatRules class variable it first needs to be instantiated, for example


Dim afrs as AutoFormatRules
Set afrs = Session.CreateSharingItem.Move.Views(1).AutoFormatRules

For Each

Here is an example of processing the AutoFormatRules items in a collection.


Dim afr As AutoFormatRule
For Each afr In Session.CreateSharingItem.Move.Views(1).AutoFormatRules
	
Next afr

Add

Creates a new AutoFormatRule object and appends it to the AutoFormatRules collection.

Duplicate names for AutoFormatRule objects are allowed in the AutoFormatRules collection. A maximum of 25 custom formatting rules can be added to the collection. Built-in formatting rules are not counted against that limit.

Add (Name)

Name: The name of the new formatting rule.


Dim strName As String: strName = 
Dim afr As AutoFormatRule
Set afr = Session.CreateSharingItem.Move.Views(1).AutoFormatRules.Add(Name:=strName)

Class

Returns an OlObjectClass constant indicating the object's class. Here you can find possible values for OlObjectClass.


Dim oocsClass As OlObjectClass
oocsClass = Session.CreateSharingItem.Move.Views(1).AutoFormatRules.Class

Count

Returns a Long value indicating the count of AutoFormatRule objects in the specified collection.


Dim lngCount As Long
lngCount = Session.CreateSharingItem.Move.Views(1).AutoFormatRules.Count

Insert

Creates a new AutoFormatRule object and inserts it at the specified index within the AutoFormatRules collection.

This method cannot be used to insert custom formatting rules between or ahead of built-in formatting rules. Duplicate names for AutoFormatRule objects are allowed in the AutoFormatRules collection. A maximum of 25 custom formatting rules can be added to the collection. Built-in formatting rules are not counted against that limit.

Insert (Name, Index)


Dim strName As String: strName = 
Dim lngIndex As Long: lngIndex = 
Dim afrInsert As AutoFormatRule
Set afrInsert = Session.CreateSharingItem.Move.Views(1).AutoFormatRules.Insert(Name:=strName, Index:=lngIndex)

Arguments

The following arguments are required:

Name (String) - The name of the new object.

Index (Long) - Either the index number at which to insert the new object, or a value used to match the Name property value of an object in the collection at where the new object is to be inserted.

Item

Returns an AutoFormatRule object from the collection.

Item (Index)

Index: Either the index number of the object, or a value used to match the Name property value of an object in the collection.


Dim afr As AutoFormatRule
Set afr = Session.CreateSharingItem.Move.Views(1).AutoFormatRules(Index:=1)

Remove

Removes an object from the collection.

If the name of a formatting rule to be removed is specified in Index, this method removes the first AutoFormatRule object that matches the specified name. Built-in formatting rules cannot be removed from the collection.

Remove (Index)

Index: Either the index number of the object, or a value used to match the Name property value of an object in the collection.


Dim lngIndex As Long: lngIndex = 
Session.CreateSharingItem.Move.Views(1).AutoFormatRules.Remove Index:=lngIndex

RemoveAll

Removes all custom formatting rules from the AutoFormatRules collection.

This method removes every AutoFormatRule object with a Standard property value set to False.


Session.CreateSharingItem.Move.Views(1).AutoFormatRules.RemoveAll

Save

Save all changes to AutoFormatRule objects within the AutoFormatRules collection.

Any changes made to the AutoFormatRules collection, such as adding or removing AutoFormatRule objects, or to an AutoFormatRule object within the collection, are persisted only if this method is called.


Session.CreateSharingItem.Move.Views(1).AutoFormatRules.Save

Session

Returns the NameSpace object for the current session.

The Session property and the GetNamespace method can be used interchangeably to obtain the NameSpace object for the current session. Both members serve the same purpose. For example, the following statements perform the same function: