Copy link to clipboard
Copied
Hello all!
I'm new to InDesign Scripting and I have been hunting around trying to find anything that would possibly work, and I just can't quite find it. I hope someone can help!
I have a book that has tons of tables in it. They are all the same table. 2 Columns by 10 rows. Here is my dilemma:
My client wants to add new rows to these tables, specifically:
Is this even possible with a script?
(I mention "already established" row, because I'm not sure if once the script adds that first row at the top, if that then changes the numbers of the rest of the rows -- and so on when more are added.)
Any help would be MUCH appreciated.
Hi,
what is a book for you? One document or a real Indesign-book-file with several documents?
One document:
var curDoc = app.activeDocument;
var allTables = curDoc.stories.everyItem().tables.everyItem().getElements();
for ( var t = 0; t < allTables.length; t++ ) {
var curTable = allTables
var allRows = curTable.rows;
curTable.rows.add(LocationOptions.AFTER, allRows[8]);
curTable.rows.add(LocationOptions.AFTER, allRows[8]);
curTable.rows.add(LocationOptions.AFTER, allRows[8]);
curTa
...Copy link to clipboard
Copied
Hi Tiggermn8278
This might help you a bit, I hope.
This is for the first table.
*********************************************************
main();
exit();
function main() {
var myDoc = app.activeDocument;
// first you need something to get hold of the tables
// this is for the first talble in the first story
var myStory = myDoc.stories[0];
var myTable = myStory.tables[0];
var ninthRow = myTable.rows[9];
myTable.rows.add(LocationOptions.BEFORE, ninthRow);
var ninthRow = myTable.rows[9];
myTable.rows.add(LocationOptions.BEFORE, ninthRow);
var ninthRow = myTable.rows[9];
myTable.rows.add(LocationOptions.BEFORE, ninthRow);
var thirdRow = myTable.rows[3];
myTable.rows.add(LocationOptions.BEFORE, thirdRow);
myTable.rows.add(LocationOptions.AT_BEGINNING);
}
*********************************************************
kind regards
Dani (from Switzerland)
Copy link to clipboard
Copied
Hi,
what is a book for you? One document or a real Indesign-book-file with several documents?
One document:
var curDoc = app.activeDocument;
var allTables = curDoc.stories.everyItem().tables.everyItem().getElements();
for ( var t = 0; t < allTables.length; t++ ) {
var curTable = allTables
var allRows = curTable.rows;
curTable.rows.add(LocationOptions.AFTER, allRows[8]);
curTable.rows.add(LocationOptions.AFTER, allRows[8]);
curTable.rows.add(LocationOptions.AFTER, allRows[8]);
curTable.rows.add(LocationOptions.AFTER, allRows[2]);
curTable.rows.add(LocationOptions.AT_BEGINNING);
}
Several closed documents in a book file:
This assumes, that only one book file is open!
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
var curBook = app.books[0];
var allDocuments = curBook.bookContents;
for ( var n = 0; n< allDocuments.length; n++ ) {
var curDoc = app.open( File( allDocuments
var allTables = curDoc.stories.everyItem().tables.everyItem().getElements();
for ( var t = 0; t < allTables.length; t++ ) {
var curTable = allTables
var allRows = curTable.rows;
curTable.rows.add(LocationOptions.AFTER, allRows[8]);
curTable.rows.add(LocationOptions.AFTER, allRows[8]);
curTable.rows.add(LocationOptions.AFTER, allRows[8]);
curTable.rows.add(LocationOptions.AFTER, allRows[2]);
curTable.rows.add(LocationOptions.AT_BEGINNING);
}
// optional
// curDoc.save();
// curDoc.close();
}
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
Copy link to clipboard
Copied
THANK YOU! It was for one document, so that script worked PERFECTLY! It was EXACTLY what I was looking for!
This just saved me HOURS of manually adding rows to over 300+ tables!
Copy link to clipboard
Copied
Hi.
I am looking for is more than simple. I think.
Iff I needed add only one roow at the botton in all tables in my active document?
Is it possible?
Copy link to clipboard
Copied
Hi,
Try this!!
curTable.rows.add(LocationOptions.AT_END);
Adobe InDesign CS6 (8.0) Object Model JS: Layer
Thanks,
Prabu