Skip to main content

Styles

  • 2 minutes to read

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

Use the CharacterStyleCollection.CreateNew and ParagraphStyleCollection.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 and ParagraphStyle.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 or the ParagraphStyleCollection.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 styles by utilizing the Style Editor Dialog.