Copy link to clipboard
Copied
Hi,
I tried to figure out how to auto format a table; googling around I did a patchwork of script snippets and eventually I came to this:
app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().properties = {autoGrow:false};
var doc = app.activeDocument;
var everyStory = doc.stories.everyItem();
var everyTable = everyStory.tables.everyItem();
var allRows = everyTable.rows.everyItem().getElements();
for (var i=1, l=allRows.length; i < l; i++) {
var row = allRows;
row.height = "2 cm";
row.width = "2 cm";
};
Now, this works fine but it seems to affect every row EXCEPT the first one. I have to stress out thatin my table there is no Header row at all.
How is this?
Thank you,
Copy link to clipboard
Copied
Hi,
JS starts counting 0.
You may shorten it:
var allRows = app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().getElements();
l = allRows.length;
for (var i = 0; i < l; i++) {
with(allRows){
//set all rowProperties here
height = "2 cm";
width = "2 cm";
autoGrow = false;
}
};
Copy link to clipboard
Copied
This is embarassing...
Thank you, hans
g
Il giorno 25/set/2012, alle ore 20:23, -hans- <forums@adobe.com> ha scritto:
var allRows = app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().getElements();
l = allRows.length;
for (var i = 0; i < l; i++) {
with(allRows){
//set all rowProperties here
height = "2 cm";
width = "2 cm";
autoGrow = false;
}
};
Copy link to clipboard
Copied
or without loop:
with(app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem()){
autoGrow:false;
height = "2 cm";
width = "2 cm";
}