Using the Word Dictionary
16
Referring to the active element
To refer to the selected, or highlighted, paragraph, table, field, or other document element, use the
selection object. From the selection object, you can access all paragraphs and other elements in the
selection. The following example applies a border around the first paragraph in the selection.
set enable borders of border options of paragraph 1 of selection to true
The following example applies a border around all the paragraphs in the selection.
set enable borders of border options of paragraph format of selection to true
The following example applies shading to the first row of the first table in the selection.
set texture of shading of row 1 of table 1 of selection to texture10 percent
An error occurs if the selection doesn't include a table. To determine whether the selection includes
a table, use the count property. The following example applies shading to the first row of the first
table in the selection.
if (count of tables of selection) 1 then
set texture of shading of row 1 of table 1 of selection to ¬
texture10
percent
else
display dialog "Selection doesn't include a table"
end if
The following example applies shading to the first row of every table in the selection. The Repeat
With...In loop is used to step through the individual tables in the selection.
if (count of tables of selection) 1 then
repeat with aTable in (get tables of selection)
set texture of shading of row 1 of aTable to texture10 percent
end repeat
end if
Working with document objects
In AppleScript, the commands for modifying files are commands of the document class.
Creating a new document
The documents list includes all of the open documents. To create a new document, use the make
command to add a document object to the documents list. The following instruction creates a new
document.
make new document