<< Click to display table of contents >>


Applies the specified style template to the selected text or paragraphs.

procedure ApplyStyleTemplate(TemplateNo: Integer; Recursive: Boolean=True);

(introduced in version 14)

This procedure assigns the specified style template to text styles or paragraph styles of items in the selected paragraphs. The result depends on the style template's Kind and the selection.


TemplateNo index in the collection Style.StyleTemplates, or the value -1. The value -1 means a format clearing (see below).

If Recursive = False, this method does not change styles in cells of selected tables (except for the case of multicell selection in a single table).


This method does nothing if UseStyleTemplates=False and TemplateNo>=0.

The method works according to the following rules:

if Kind of the specified style template = rvstkText, it is applied to the selected text;

if Kind of the specified style template = rvstkPara, it is applied to the selected paragraphs; the only exception is "Normal" style template;

if TemplateNo=-1, or Kind of the specified style template = rvstkParaText, or this is a "Normal" style template, the result depends on the selection. If nothing is selected, or the whole paragraph is selected, or the selection includes multiple paragraphs/cells, the method applies to the selected paragraphs. Otherwise, it applies to the selected text.


The method clears additional formatting, like ApplyTextStyleTemplate or ApplyParaStyleTemplate called with ResetAdditionalFormatting=True.

The method skips paragraph styles having rvpaoStyleProtect in their Options, and text styles having rvprStyleProtect in their Protection.

Format clearing

The method clears text or paragraph formatting in two cases: when it is called with TemplateNo=-1, or when it applies "Normal" style template. The results of format clearing is described in the topics about ApplyTextStyleTemplate and ApplyParaStyleTemplate.

Method type: editstyle editing-style.

See also: