1 Reply Latest reply on Feb 13, 2008 8:15 AM by (Jeff_Lambert)

    [AS CS3] how to affect only some cells in a table selection?

      I'm looking for a way to format tables with AS. I've got the part where you edit the whole table, but I have problem when I want to edit a selection of that table. Let say I have done the basic formating of the table and now I want to highlight some numbers (think annual report tables here). So, I want to put the first row of my selection (the numbers columns) and put it green, then set the character style, then do a tint of that same color on the rest of the selected cells in those columns and set another character style. The thing is, I never know how many columns I'll select, maybe 1, 2, 5, it all depend on the table, and all table don't have the same number of column either.

      I can do it for only one column, but it brakes when I try to make it work on multiple columns at once.

      Here's the script to make it work on a one column basis. IT's not what I was describing above but you get the idea anyway.

      tell application "Adobe InDesign CS3"
      tell active document
      set mycolor40 to swatch "VERT 127-3-3-C 40%"
      set mycolor10 to swatch "VERT 127-3-3-C 10%"
      tell text 1 of cells of selection
      set applied character style to "TX semibold"
      end tell
      tell cell 1 of selection
      set fill color to mycolor40
      end tell
      tell cells 2 thru -1 of selection
      set fill color to mycolor10
      end tell

      end tell
      end tell

      I've tried with

      tell cells of row 1 of selection

      and it doesn't work because it affects the whole table and not just the selection. I guess I have to count the column or something like that, but I don't know how exactly to achieve this.

      TIA
      Jeff
        • 1. Re: [AS CS3] how to affect only some cells in a table selection?
          Level 1
          Well, nothing like a few hours of applescript to figure things out:-)

          here's what I came up with
          tell application "Adobe InDesign CS3"
          tell active document
          set MyEnteteStyle to "Header"
          set MyBoldStyle to "bold"
          set MyTotalStyle to "total"

          --set the whole selection
          tell text 1 of cells of selection
          set applied character style to MyBoldStyle
          end tell

          --set the first line of selection
          tell first cell of every column of selection
          tell text 1
          set applied paragraph style to MyEnteteStyle
          end tell
          end tell

          --set the last line of selection
          tell last cell of every column of selection
          tell text 1
          set applied paragraph style to MyTotalStyle
          end tell
          end tell
          end tell
          end tell

          Hope this helps somebody else.

          Jeff