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 the 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. You should create a new style and copy its properties, one by one. When performing mail merge, use the MailMergeOptions.CopyTemplateStyles property to copy template styles to the merged document.

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

See Also