[Date Prev][Date Next]
[Thread Prev][Thread Next]
[Date Index]
[Thread Index]
[New search]
To: Ludwig Geier <ludwig.geier@xxxxxxxxxx>, framers@xxxxxxxxxxxxxx (Framers List)
Subject: Re: set contents of cells by AppleScript
From: Larry Kollar <Larry.Kollar@xxxxxxxxxxx>
Date: Tue, 13 Feb 2001 16:35:27 -0500
In-Reply-To: <LYRIS-45500-7588-2001.02.13-10.03.28--Larry.Kollar#arris-i.com@lists.frameusers.com>
Sender: owner-framers@xxxxxxxxx
Ludwig Geier wrote: >I want to manipulate the contents of table cells by the foll. AppleScript. [...] set myData to (get text of every cell of selection) [...] set text of every cell of selection to (myData as list) -- <-- Wrong [...] >To get the contents of the selected cells work fine, but the update of these >cells is wrong. >Ex. the contents of myData is {"a","b","c"} >after the update in all selected cells: "abc" You'll have to update one cell at a time, instead of trying to do them all at once. This was an interesting problem, involving working around an apparant Frame bug. If you're working with a selection of cells, "selection" looks something like this: column 2 of body rows 2 thru 5 of table 1 of document .... The problem is, "count cells of selection" or "count body rows of selection" doesn't work -- at least inside "tell document"! Since each cell refers to the document it belongs to, you just need to ask the document for the selection, then you're done with it. The following snippet appends " hi" to the text of each cell in the selection -- I just tried it, and it works. You would probably want to wrap the "tell document" in a "try/on error" construct for error checking. Perhaps Bill Briggs can weigh in with a better way of doing this, too. (* begin code snippet - MacOS 8.5.1 *) set AppendText to " hi" tell application "FrameMaker+SGML 6.0" tell active document set myCells to selection end tell -- Append text to end of each cell set myData to (get text of myCells) set n to (count myData) -- get # of cells repeat with i from 1 to n set text of (cell i of myCells) to (item i of myData) & AppendText end repeat end tell (* end of code snippet *) That should get you going. Larry ** To unsubscribe, send a message to majordomo@omsys.com ** ** with "unsubscribe framers" (no quotes) in the body. **