Skip to main content
A newer version of this page is available. .

Styles

  • 2 minutes to read

The document model contains collections of styles. There are three types of styles - a paragraph style, a character style and a table style. Styles are accessible via the Document.CharacterStyles, Document.ParagraphStyles and the Document.TableStyles properties respectively.

Use the CharacterStyleCollection.CreateNew, ParagraphStyleCollection.CreateNew and TableStyleCollection.CreateNew methods to create new styles.

When creating a new style, you do not have to specify all formatting properties. Instead, you can specify the parent style (CharacterStyle.Parent, ParagraphStyle.Parent and teh TableStyle.Parent properties), and modify only the required characteristics.

Styles can be linked. A linked style can act as a paragraph style or a character style, depending on the range to which it is applied. If a linked style is applied to a selection that does not include an entire paragraph, the selected text is formatted with the character formatting settings of the linked styles. If a selection includes an entire paragraph, both character and paragraph formatting settings are applied. If a selection is just a caret position and contains no characters, the linked style behaves like a paragraph style.

You can delete a style from the collection of styles in the document, using the CharacterStyleCollection.Delete, the ParagraphStyleCollection.Delete or the TableStyleCollection.Delete methods. A deleted style can no longer be applied to text or saved in a document file.

Styles are inherent to the document, so you cannot add a style, contained in the style collection of one document, to the style collection of another document. When performing mail merge, use the CopyTemplateStyles property to copy template styles to the merged document.

End-users can modify existing document styles by utilizing the Style Editor Dialog.

See Also