Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie, iterating over contents of a selection

20 views
Skip to first unread message

Justin C

unread,
Jul 11, 2012, 8:39:41 AM7/11/12
to

I'm using Adobe InDesign, I a table in which I have selected
some cells. I want my AppleScript to look at the contents of
each selected cell and change an attribute (fill color) of the
cell if the text is "N".

So I have:
tell application "Adobe InDesign CS2"
if (count documents) is greater than 0 then
-- we have a document to work with
set mySelection to selection
if (count of mySelection) is greater than 0 then
-- we have something selected - good!
if class of item 1 of selection is contained by {cell}
-- what is selected contains table cells
-- from here I try to access each cell:
set myCells to item 1 of mySelection
repeat with myCell in myCells
set myText to text of myCell
display dialog myText
end repeat
else
display dialog "You have not selected any table cells"
end if
else
display dialog "There is nothing selected"
end if
else
display dialog "There is no InDesign document open"
end if
end tell

This gives me an error saying "Can't make {"contents of all of
the table cells","even if they're empty","","","something
else"} into type string"

It looks to me like I'm not getting the individual table cells
in the line
set myCells to item 1 of mySelection

Does anyone know how I might get at each individual table cell
in the selection?


Justin.

--
Justin C, by the sea.

Patrick Stadelmann

unread,
Jul 11, 2012, 11:22:59 AM7/11/12
to
In article <dp80d9-...@zem.masonsmusic.co.uk>,
Justin C <justi...@purestblue.com> wrote:

> It looks to me like I'm not getting the individual table cells
> in the line
> set myCells to item 1 of mySelection

It might be that the selection contains a table, so you should do
something like :

set myTable to item 1 of mySelection
set myCells to cells of myTable

If it doesn't work, look at the class of myTable to try to see what the
problem is.

Patrick
--
Patrick Stadelmann <Patrick.S...@unine.ch>

Justin C

unread,
Jul 13, 2012, 6:28:44 AM7/13/12
to
On 2012-07-11, Patrick Stadelmann <Patrick.S...@unine.ch> wrote:
> In article <dp80d9-...@zem.masonsmusic.co.uk>,
> Justin C <justi...@purestblue.com> wrote:
>
>> It looks to me like I'm not getting the individual table cells
>> in the line
>> set myCells to item 1 of mySelection
>
> It might be that the selection contains a table, so you should do
> something like :
>
> set myTable to item 1 of mySelection
> set myCells to cells of myTable


Spot on! Thank you for your help. It is correct that,
even though the selection is only certain columns of
the table, 'item 1 of mySelection' is indeed a table.

Back to the InDesign dictionary in ScriptEditor to
figure out the next bit.

Thanks again for your help, I don't think I'd have
got this without help.


> If it doesn't work, look at the class of myTable to try to see what the
> problem is.
>
> Patrick


0 new messages