CountStyles()

Syntax

CountStyles([Context] [All])

Remarks

Returns the number of styles defined for the specified context.

Argument

Explanation

Context

Specifies the location of styles to count:

0 (zero) or omitted Active document

1 Active template

All

Specifies whether to include built-in styles:

0 (zero) or omitted Built-in styles are excluded.

1 Built-in styles are included.

Note that Word contains 75 built-in styles, and that two of those built-in styles are defined by default: Default Paragraph Font and Normal.


Examples

This example returns the number of all built-in styles plus the number of user-created styles used in the template attached to the active document:


n = CountStyles(1, 1)

The following example merges styles into the active document from the attached template. Then, the macro finds the number of styles defined just for the document, if any, by subtracting the number of styles defined for the template from the number of styles defined for the document.


FormatStyle .Source = 1, .Merge
n = CountStyles(0, 0) - CountStyles(1, 0)

See Also

StyleName$()