RichText.SetSelectionFormat

RichText.SetSelectionFormat ( 

string  ObjectName,

table   CharacterFormat,

boolean ApplyToWord = false )

Description

Sets the character formatting of the current selection in a richtext object.

Parameters

ObjectName

(string) The name of the richtext object.

CharacterFormat

(table) A table containing the format settings you want to modify in the richtext object, indexed by the following items.

Note: Some of the following table items are included only for compatibility with Microsoft Text Object Model (TOM) interfaces; the rich edit control stores the value but does not use it to display text. The functionality of some of the items may also depend on the version of the rich edit control available on the system.

KEY

TYPE

DESCRIPTION

AllCaps

boolean

True to set the selected characters as all capital letters and false to not. This value applies only to versions earlier than Rich Edit 3.0.

AutoBackColor

boolean

True to use the background color of the object's background color for selected text (ignore BackColor), false if BackColor should be used.

AutoColor

boolean

True to use the text color of the objects text color for selected text (ignore TextColor), false if TextColor should be used.

Bold

boolean

True if the selected text should be bolded, false if it should not.

Disabled

boolean

True if characters should be displayed as disabled, false if they should not.

Emboss

boolean

True if the characters should be embossed, false if they should not. (This item has no effect on displayed text in the object.)

Hidden

boolean

True if the characters should be displayed, false if they should not. This item is only supported for Rich Edit 3.0 and later.

Imprint

boolean

True if characters should be displayed as imprinted characters, false if they should not. (This item has no effect on displayed text in the object.)

Italic

boolean

True if characters should be italic, false if they should not.

Link

boolean

True if the selection should contains links, false if it should not.

Outline

boolean

True if characters should be displayed as outlined characters, false if they should not. (This value has no effect on displayed text in the object.)

Protected

boolean

True if the characters should be protected, false if they should not.

Revised

boolean

True if characters should be marked as revised, false if they should not.

Shadow

boolean

True if the characters should be displayed as shadowed characters, false if they should not. (This value has no effect on displayed text in the object.)

SmallCaps

boolean

True if characters should be in small capital letters, false if they should not. (This value has no effect on displayed text in the object.)

StrikeOut

boolean

True if characters should be struck out, false if they should not.

SubScript

boolean

True if the characters should be subscript, false if they should not.

SuperScript

boolean

True if the characters should be superscript, false if they should not.

Underline

boolean

True if the characters should be underlined, false if they should not.

Height

number

The height of the characters to set in twips.

YOffset

number

The character offset from the baseline to set, in twips. If this value is positive, the character is a superscript; if the value is negative, the character is a subscript.

TextColor

number

The text color to set. This item is ignored if AutoColor is set to true.

CharacterSet

number

The character set of the text to use:

CONSTANT

VALUE

DESCRIPTION

ANSI_CHARSET

0

ANSI character set.

BALTIC_CHARSET

186

Baltic character set.

CHINESEBIG5_CHARSET

136

Chinese character set.

DEFAULT_CHARSET

1

Default character set.

EASTEUROPE_CHARSET

238

Eastern European character set.

GB2312_CHARSET

134

GB2312 character set.

GREEK_CHARSET

161

Greek character set.

HANGUL_CHARSET

129

Hangul character set.

MAC_CHARSET

77

MAC character set.

OEM_CHARSET

255

OEM character set.

RUSSIAN_CHARSET

204

Russian character set.

SHIFTJIS_CHARSET

128

Shiftjis character set.

SYMBOL_CHARSET

2

Symbol character set.

TURKISH_CHARSET

162

Turkish character set.

PitchAndFamily

number

The font family and pitch to use. See MSDN: CHARFORMAT2 Structure for more information.

FaceName

string

The name of the font to use in the selected text.

Weight

number

The weight of the font to use (how 'dark' the text is):

CONSTANT

VALUE

DESCRIPTION

FW_DONTCARE

0

Font weight not specified.

FW_THIN

100

Font weight 'thin'.

FW_EXTRALIGHT

200

Font weight 'extra-light'.

FW_LIGHT

300

Font weight 'light'.

FW_NORMAL

400

Font weight 'normal'.

FW_MEDIUM

500

Font weight 'medium'.

FW_SEMIBOLD

600

Font weight 'semi-bold'.

FW_BOLD

700

Font weight 'bold'.

FW_EXTRABOLD

800

Font weight 'extra bold'.

FW_HEAVY

900

Font weight 'heavy'.

Spacing

number

The horizontal space between letters to use, in twips. (This value has no effect on displayed text in the object. It is included for compatibility with Microsoft WindowsText Object Model (TOM) interfaces.)

BackColor

number

The background color to set. This value is ignored if AutoBackColor is set to true.

LCID

number

The locale identifier of the selected text to use. (This value has no effect on displayed text in the object.) See MSDN: CHARFORMAT2 Structure for more information.

Kerning

number

The value of the font size, above which to kern the character (Height). (This value has no effect on displayed text in the object. It is included for compatibility with Microsoft WindowsText Object Model (TOM) interfaces.)

Style

number

The character style handle. (This value has no effect on displayed text in the object. It is included for compatibility with Microsoft WindowsText Object Model (TOM) interfaces.)

UnderlineType

number

The underline type to use specified by one of the following values:
CFU_CF1UNDERLINE (255) - Contains a CHARFORMAT type of underline.
CFU_UNDERLINENONE (0) - No underline. This is the default.
CFU_UNDERLINE (1) - Solid underlined text.
CFU_UNDERLINEWORD (2) - Underline words only. The object displays the text with a solid underline.

CFU_UNDERLINEDOUBLE (3) - Double-underlined text. The object displays the text with a solid underline.
CFU_UNDERLINEDOTTED (4) - Dotted underlined text. For versions earlier than Rich Edit 3.0, text is displayed with a solid underline.

Animation

number

The text animation type to use. (This value has no effect on displayed text in the object. It is included for compatibility with TOM interfaces.)

RevAuthor

number

An index that identifies the author making a revision. The rich edit control uses different text colors for each different author index.

ApplyToWord

(boolean) Whether to apply the formatting to any words the selection covers (or the insertion point is in), or to apply the formatting only to the selected characters (or to new characters entered at the insertion point if nothing is selected).

VALUE

DESCRIPTION

true

Apply formatting to any words the selection covers.

false

Only apply formatting to selected characters. (Default)

Returns

Nothing. You can use Application.GetLastError to determine whether this action failed, and why.

See also:  Related Actions