AppleWorks Scripting Problems


but not perfect.


AppleWorks has a rich AppleScript dictionary. However, there are a few problems with the AppleScript support (especially in AppleWorks 5) that require some particular work arounds or which prevent some functions altogether.

AppleWorks 5
Dictionary Holes


In AppleWorks 5, much of the features offered by the dictionary were not actually supported, which we define as a “hole”. This lead to great frustration and guesswork. This page lists the common occurrences. Thankfully, AppleWorks 6 has few such holes.

Trouble Shooting


For information on running (not writing) prepared scripts, compatibility problems and some fixes, see our troubleshooting page for the Enhancement Pack set of scripts.


Every Record Whose Visible is True
Problem in AppleWorks 6.2.4 (and some earlier?) on Mac OS X (and 9?)

You should be able to (and it used to work) get a reference to the visible records in a database with:

every record of database of front document whose visible is true

but it returns the hidden records.

Work Around
Ask for the records that are not invisible:

every record of database of front document whose visible is not false

Accessing Spreadsheet Frame
Problem in AppleWorks version: 5 and 6?

Following the AppleWorks AppleScript dictionary, for a floating spreadsheet in a word processing doc, the required syntax is:

tell application "AppleWorks"
  tell spreadsheet of spreadsheet frame 1 of drawing area of document 1
    set cell "A1" to "1234"
  end tell
end tell

The above works.

For an in-line spreadsheet (ie like a character in the text), the dictionary suggests that the syntax should be:

tell application "AppleWorks"
  tell spreadsheet of spreadsheet frame 1 of drawing area of character 1 in text body of document 1
    set cell "A1" to "1234"
  end tell
end tell

but that fails.

Work Around
Can probably work around it by scripting a copy and paste of the frame, change it, then paste back.

Call Built in Operations
Problem in AppleWorks versions: 5 & 6

Need to be able to call built in buttons. do script does not work for buttons such as New URL Link, Make Table.

Appropriate refreshing should be done when a script affects objects, after the script has completed.

There are many instances, including:
    1. A text frame does not reposition the characters when AppleScript changes the font size.
    2. A database list is not redrawn when records are deleted.

Macro Function Uppercase
Problem in AppleWorks versions: 5 & 6

A spreadsheet cell or database field can contain the MACRO function to call an AppleScript. The general format is =MACRO(<script file name>, 2, <procedure name>, <data1>, <data2>, etc). It works fine, but fails if <procedurename> contains any uppercase letters.

Macro Function Numeric Parameter
Problem in AppleWorks version 5, fixed in 6.

If a data parameter refers to a cell or field which is not text (such as numeric), the MACRO function has to coerce it to text with something like: 'A1'&"" or NUMTOTEXT('A1').

Elements in Selection
Problem in AppleWorks version 5, fixed in 6.

In most cases it is difficult to address specific items within the selection. For example, the following fails:

item 1 in selection -- where multiple graphic objects are selected

Selected Text in Field
Problem in AppleWorks version 5 and 6.

Cannot address the selected text in a database field.

Problem in AppleWorks version 5, fixed in 6.

The file property fails if the document was opened with read only permission (eg on a file server). Most of the properties of a document fail. See the dictionary page.

Page Number
Problem in AppleWorks version 5, fixed in 6.

There is no way to get the page of an object or the content of a particular page.

Text Nested Elements
Problem in AppleWorks version 5, fixed in 6.

A reference to an object three levels deep, fails. eg character 2 in paragraph 3 in text body.

Work Arounds
Two work arounds are possible:

    1. Copy the text to a temporary document. This is especially convenient when the outer object is the current selection. It has the advantage of also allowing the user to undo the final paste to revert to the state before the script was run.
      select paragraph 3 in text body...
      copy to clipboard
      make new document at front
      character 2 in text body of front document
    2. Calculate the character number to remove the middle object reference.
      set charN to offset of paragraph 3
      character charN + 2

User Styles
In AppleWorks 5, name property of user style is incorrectly "Untitled xx" rather than the actual name of the style.

AppleWorks 6 removed the “user style” property and introduced “paragraph style”. It provides just the name of the style. AppleWorks 6 offers no way to access the other user styles such as styles of characters and graphic objects

Check Spelling
AppleWorks 5 provided a “check spelling” event:

check spelling
[of reference] -- the object or text to spell-check
   [dialog boolean] -- display a dialog showing the misspelled words?
  Result: list] -- list of misspelled words

The reference would fail for a reference to an AppleWorks object, such as “text body of front document”. It would accept a text object, so you could simply coerce like “(text body of front document) as text”.

AppleWorks 6 removed the check spelling event altogether, with no replacement.

Problem in AppleWorks version 6, OK in 5.

The “speak” event will only accept a reference to an AppleWorks object, such as text body of document, but won’t accept literal text, such as “hello” or an expression such as “hello “ & word 5 in text body.

Work Around
The standard scripting additions should include a “say” command. So use “speak” for any AppleWorks objects and “say” for literal text or expressions (including those involving AppleWorks objects).

Problem in AppleWorks version 5, fixed in 6?

Accessing text properties of a header will crash the computer. eg font of character 1 in header of front document. It will crash even if the text in the header is selected and the properties of the selection are manipulated.

Work Around
AppleScript can set some text properties of the selection by selecting menu items, eg select menu item "Bold" in menu "Style". So, if the selection is in the header, the header can be indirectly manipulated. Selecting the header is not easy. The simplest way is to create the header which places the cursor in it. In some circumstances a macro called by "do script" might work.

Nested property reference
Often need to set up a temporary variable to reference a nested property.

This fails:
<property> of user style of...
This works:
set myStyle to user style of...
<property> of myStyle

This fails:
<property> of record 1
This works:
set myRecord to record 1
<property> of myRecord

Problem in AppleWorks version 5, fixed in 6.

Cannot use the every operator as expected.

This fails:
repeat with thisParagraph in every paragraph
This works:
set paragraphCount to count every paragraph
repeat with paragraphN from 1 to paragraphCount
set thisParagraph to paragraph paragraphN

Field Value
Problem in AppleWorks version 5, fixed in 6?

Cannot set the value of a field.

Need weird syntax to get value of a field.

This fails:
field <fieldname> of myRecord
This works:
<fieldname> of myRecord - if <fieldname> is not a reserved word
|<fieldname>| of myRecord - if <fieldname> is a reserved word

Need to be able to use form field <fieldname> to allow field names to be determined by variables.

It turns out that if a field is empty, AppleWorks returns the name of the next field as the value of the first. If there is not an even number of empty fields, then the script just fails.

Cannot select a field. Can sometimes work around by recording a macro to select the first record via a click, then call that macro via do script. Very messy. Contribution by Peter Vollmer <>.

Delete record deletes all but one or two. 99.06.12

Field Definitions
AppleWorks 5 cannot make fields. AppleWorks 6 can, except for calculated fields.

graphic object
Problem in AppleWorks version 5, fixed in 6.

Various properties fail, including fill color, fill pattern, fill gradient, fill texture, pen pattern etc.

duplicate: fails
exists: returns true if exists but returns error if doesn't exist
make: fails for new spreadsheet frame, text frame, paint frame. Makes a rectangle.
make: must specify properties with at least one label and value, but only bounds will actually work.
make: Accepts at front, at end or at back, but still makes at front.
move: fails

Problem in AppleWorks version 5, fixed in 6.

Using "chart" in a script compiles as "chart legend". Discovered by Dennis Tokaryk, 1999.10.30.

In AppleWorks 5, all properties fail.

AppleWorks 6 can manipulate a movie as a graphic object (eg adjust bounds), but no specific movie properties.

In AppleWorks 5, polygon (also used for a bezier) is made up of vertices. But all properties of the vertex fail.

AppleWorks 6 can make a polygon “with data {{x1,y1}, {x2,y2} etc}”, but cannot adjust or read existing polygons. AppleWorks 6.0 and 6.0.3 makes a phantom point at the end of a polygon.

text frame
In AppleWorks 5, make new text frame fails, producing a rectangle instead. In AppleWorks 6 it works but if bounds are not specified, it spans 42 pages! Fixed in AppleWorks 6.0.3.

Problems in AppleWorks version 5, fixed in 6.

When asked for cell 1, there is no problem. But a request for cell 2 (or cell {2,1}) will return cells 2 and 3. A request for cell 3 will return cells 3, 4 and 5. To work around this bug, just prefix these references with "cell 1 in", such as "cell 1 in cell 3 in..."

Reference to cells by alpha numeric grid, eg cell "A1", works OK.

Cannot set the formula of a cell, but can set the cell itself to be the formula (ie set cell "A3" to "=A1+A2").

If the formula contains a reference to a cell past the Z column, AppleWorks will crash. eg "=SUM(AA45..AA55)"

AppleWorks 5 has trouble "coercing" numbers to text. If you look at AppleWorks 5 AppleScript dictionary, the formula of a cell is of class "text". However, you would assume that given a number, AppleWorks would happily coerce it to text. Unfortunately, in this case, it converts it to some kind of text style, such as “set cell "A1" to 2, instead inserts the text "ital". If you want to force the correct coercion, you use the "as" operator. For instance, 2 as text is "2".

AppleWorks 5 and 6.0 had problems setting a cell border (such as left border) to false, having the side affect of enabling the three other borders. This bug is fixed in 6.0.3.

sort cells
In AppleWorks 5, the sort event (for cells in a spreadsheet) does not work at all.

In AppleWorks 6.0:

sort reference -- the cell range to sort
[with orientation horizontal/vertical] -- sort horizontally (swap columns), or vertically (swap rows) [default is vertical]
[with data a list of list] -- names and directions on which to sort e.g. {{"A1",descending},{"B1",ascending}} [default is upper-left cell, ascending]

horizontal sorts vertical and vertical sorts horizontal. ascending and descending both sort descending, so there is no way to sort ascending.

Contributed by Vincent Jalby 2000.03.01.

This bug is fixed in AppleWorks 6.0.3.

More soon.

Please post any questions about scripting AppleWorks to one of the discussion forums on our links page.