Apply styles by scripts

Build 1501 on 14/Nov/2017  This topic last edited on: 8/Jan/2016, at 17:14

You can apply styles on text by scripts. Use standard scripts or create custom scripts, and assign them to keyboard shortcuts or menu commands.

Examples

This script applies the paragraph style with the style name byline on the selected paragraphs and returns True if applied successfully, or displays a message if the style cannot be applied:

SetParaStyleMsg ("byline")

This script applies the character style with the style name shrunk on the selected text and returns True if applied successfully, or displays a message if the style cannot be applied:

SetTextStyleMsg ("shrunk")

This script applies the paragraph style with the tag name head3 (skipping all parameters, if any) on the selected paragraphs:

Dim objStyle = Text.GetParaStyle

objStyle.SetName("head3")

Text.SetParaStyle(objStyle)

 

This script applies the paragraph style with the tag name head3 (with one parameter) on the selected paragraphs:

Dim objStyle = Text.GetParaStyle

objStyle.SetName("head3")

objStyle.SetPar(0, Units.ToVal("36pt"))

Text.SetParaStyle(objStyle)

 

This script applies the character style with the tag name up on the selected text:

DIm objStyle = text.gettextstyle

Objstyle.setname = "up"

Text.SetTextStyle(objstyle) 

This script applies the paragraph style with the style name ([Auto]) on the selected paragraphs:

Text.EditParaStyle("[Auto]")

 

Related commands

EditParaStyle, EditParaStyleAll, EditParaStyleChain, EditParaStyleDlg

See also

Styles and scripting