Using the Word Dictionary
22
Applying formatting to text
This topic includes information and examples related to the following tasks:
·
Applying formatting to the selection
·
Applying formatting to a text range
·
Inserting text and applying character and paragraph formatting
·
Toggling the space before a paragraph between 12 points and none
·
Increasing the left margin by 0.5 inch
Applying formatting to the selection
The following example uses the selection object to apply character and paragraph formatting to the
selected text. To access character formatting properties, use the font object property. To access
paragraph formatting properties and commands, use the paragraph format property.
set fSel to font object of selection
set name of fSel to "Times New Roman"
set font size of fSel to 14
set all caps of fSel to True
set pSel to paragraph format of selection
set paragraph format left indent of pSel to (inches to points inches 0.5)
space 1 pSel
Applying formatting to a text range
The following example defines a text range object that refers to the first three paragraphs in the
active document. The text range (
myRange
) is formatted by applying properties of the font and
paragraph format objects.
set myRange to create range active document start (start of content of ¬
text object of paragraph 1 of active document) end (end of content ¬
of text object of paragraph 3 of active document)
set name of font object of myRange to "Arial"
set alignment of paragraph format of myRange to align paragraph justify