Skip navigation
Currently Being Moderated

Tables - Row Height and Cell Insets

Aug 30, 2012 7:09 AM

Tags: #tables #row_height #cell_inset

I am working on ascript to do the following:

 

1. Set the first Row of all tables in my doc to these settings:

  • Row Height = .25in
  • Top and Bottom Inset = .04in

 

2. Set rest of the cells to these settings:

  • Row Height = .12in
  • Top and Bottom Inset = .12in

 

Here is where I am at:

 

 

app.activeDocument.stories.everyItem().tables.everyItem().rows[0].heig ht = ".25 in";

app.activeDocument.stories.everyItem().tables.everyItem().rows[0].topI nset = ".04 in";

app.activeDocument.stories.everyItem().tables.everyItem().rows[0].bott omInset = ".04 in";

 

 

for( x = 1; x < app.activeDocument.stories.everyItem().tables.everyItem().rows.length ; x++ ) {

app.activeDocument.stories.everyItem().tables.everyItem().rows[x].heig ht = ".12 in";

}

 

 

for( x = 1; x < app.activeDocument.stories.everyItem().tables.everyItem().rows.topIns et; x++ ) {

app.activeDocument.stories.everyItem().tables.everyItem().rows[x].topI nset = ".12 in";

}

 

 

for( x = 1; x < app.activeDocument.stories.everyItem().tables.everyItem().rows.bottom Inset; x++ ) {

app.activeDocument.stories.everyItem().tables.everyItem().rows[x].bott omInset = ".12 in";

}

 

 

 

I keep getting this error and I am stuck.

 

error-1.jpg

 

Anyone see anything that would help?

 

Thanks in advance.

 
Replies
  • Currently Being Moderated
    Aug 30, 2012 8:14 AM   in reply to lazycarpenter

    There is indeed an extra closing parentheses on that line in the screenshot (but not in your sample lines).

     

    I wonder if this construction

     

    for( x = 1; x < app.activeDocument.stories.everyItem().tables.everyItem().rows.length ; x++ ) {
    app.activeDocument.stories.everyItem().tables.everyItem().rows[x].heig ht = ".12 in";
    }
    

     

    every could work ... The for..loop expects a simple end number, but you feed it with an array of all of your individual tables' row lengths.

     

    If this indeed does not work, turn your script around. Set all of the row heights and insets using

     

    app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().topInset = ".12 in";
    

     

    and after that run the lines to do the top row adjustments.

     

    (Use "Advanced editor" to be able to set Javascript syntax highlighting -- it makes your code ever so slightly more readable.)

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 30, 2012 11:11 AM   in reply to lazycarpenter

    Excuse me but I'm having a hard time understanding where things are going to go in these cells. With a top and bottom inset the same size as the height, it doesn't seem to leave much room for the text.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 30, 2012 12:21 PM   in reply to lazycarpenter

    I think Jongware has it right. Set the whole table first and then adjust the first row.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points