2 Replies Latest reply on Jan 13, 2011 5:16 PM by rottenuncle

    AS: Select odd & even table columns

    rottenuncle Level 1

      I'm trying to set up some fairly complicated table formatting and need to different text insets, strokes, etc to alternating columns. Can't seem to figure out how to select alternating columns. I tried the following:

       

      set myColumns to every column of myTable whose (index mod 2) = 0

      but got "error "Can’t make index into type number." number -1700 from index to number" despite the fact that the columns index is supposed to be an integer.
      Any ideas?

        • 1. Re: AS: Select odd & even table columns
          L. Guy O'Rojo Level 2

          You could process it one column at a time:

           

          tell application "Adobe InDesign CS4"

          activate

          tell document 1

          tell page 1

          tell page item 1 -- a text frame with a table in it

          set myColumns to {}

          tell table 1

          repeat with i from 1 to (count columns)

          if i mod 2 is 1 then -- odd column

          set myColumns to myColumns & (a reference to column i)

          select (a reference to column i) -- show selected column, or do whatever to this column

          delay 1 -- for demo purposes

          end if

           

          end repeat

          end tell

           

          end tell

          end tell

          end tell

          end tell

           

          return myColumns

          -->  {column 1 of table id 251 of text frame id 247 of page id 190 of spread id 185 of document "Untitled-1" of application "Adobe InDesign CS4", column 3 of table id 251 of text frame id 247 of page id 190 of spread id 185 of document "Untitled-1" of application "Adobe InDesign CS4"}

          • 2. Re: AS: Select odd & even table columns
            rottenuncle Level 1

            That's essentially what I ended up doing:

             

            tell myTable

            repeat with i from 1 to n    -- n = 1/2 column count

            set myOddColumn to column (2 * i - 1)

            tell myOddColumn

            set left inset of every cell ...

            set bottom inset of every cell ...

            set left edge stroke type ...

            etc...

            end tell

            set myEvenColumn to column (2 * i)

            tell myEvenColumn

            set right inset of every cell ...

            set bottom inset of every cell ...

            set right edge stroke type ...

            etc...

            end tell

            end repeat

            end tell