Copy link to clipboard
Copied
Hello all,
I have a series of large Arabic documents where I need to flip the table direction to RTL. I've cobbled together the following:
var a = app.activeDocument.textFrames.everyItem().tables.everyItem().getElements();
for (var i=a.length-1; i > 0; i--){
a.tableDirection = TableDirectionOptions.RIGHT_TO_LEFT_DIRECTION;
}
It seems to work but doesn't catch every table - what have I left out?
And shouldn't it be "i >= 0"?
Copy link to clipboard
Copied
Hi,
maybe it is worth a try to use "stories" instead of "textFrames"?
var a = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
BR
Jan
Copy link to clipboard
Copied
Hi Jan
Thanks - I did try this but "stories" still does not pick up every table.
Copy link to clipboard
Copied
And shouldn't it be "i >= 0"?
Copy link to clipboard
Copied
Ha, thank you! How elementary ![]()
Copy link to clipboard
Copied
![]()
Copy link to clipboard
Copied
it should be
i >= 0
Copy link to clipboard
Copied
Please try without the loop. If you assign a value to everyItem().someProperty, it should modify each referenced object.
app.activeDocument.stories.everyItem().tables.everyItem().tableDirection = TableDirectionOptions.RIGHT_TO_LEFT_DIRECTION;
Dirk
Copy link to clipboard
Copied
Hi Dirk
For the nested tables one would add
app.findTextPreferences.findWhat = "\x16";
then loop though the results and change direction as required
Trevor
Copy link to clipboard
Copied
Hi Trevor,
thanks for bringing up nested tables. Do you mean tables nested in table cells? That would be:
app.activeDocument.stories.everyItem().tables.everyItem().tableDirection = TableDirectionOptions.RIGHT_TO_LEFT_DIRECTION;
app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().tables.everyItem().tableDirection = TableDirectionOptions.RIGHT_TO_LEFT_DIRECTION;
Probably it is a good idea to add some try/catch if any of the expressions yields no hits, e.g. the doc has no tables.
Dirk
Copy link to clipboard
Copied
Hi Dirk
Yes, but if you want to catch those really common tables nested in cells of tables nested in cells etc. then ![]()
See https://forums.adobe.com/message/6087936#6087936
Trevor
Copy link to clipboard
Copied
Hi Dirk
This will get all the nested tables regardless of their depth, although I am not certain whether this or the Grep method would be faster for very lager documents with large amounts of nested levels.
var doc = app.activeDocument, t;
(t = doc.stories.everyItem().tables.everyItem()).tableDirection = TableDirectionOptions.RIGHT_TO_LEFT_DIRECTION;
while (t.cells.length) (t = t.cells.everyItem ().tables.everyItem ()).tableDirection = TableDirectionOptions.RIGHT_TO_LEFT_DIRECTION;
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more