Using scripts for advanced table sculpting – help needed
Learn / Forums / General InDesign Topics / Using scripts for advanced table sculpting – help needed
- This topic has 4 replies, 2 voices, and was last updated 7 years, 7 months ago by Matt Isaac.
-
AuthorPosts
-
-
August 30, 2016 at 7:26 am #87918Martin KoreckýMember
Hey guys,
I would definitely apreciate any help with this issue. Forr better undesrtanding I am attaching an image.https://s11.postimg.org/a8sadr0oz/screen.png
My problem is, that I have a LOT of tables with 5 columns, a an image anchored in last cell of the first row. Client now wants to delete last two column in every table, but this results in deleting my anchored image also. I would need a script, which will do the following:
1: cancel the cell merging in first row
2: merge first two cells and then last three cells in first row together
3: select the last two columns in a table and delete themthis should prevent deleting the anchored image, which is cruicial to me. Problem is that I am no scripter and have no idea how to do this. Doing this manually in 490 tables is quite annoying only by thinking about it. Anyone have an advice? I would be very grateful.
-
August 30, 2016 at 2:02 pm #87932Matt IsaacParticipant
var doc = app.activeDocument;
var tables = doc.textFrames.everyItem().tables.everyItem();
tables.rows[0].unmerge();
tables.cells[0].merge(tables.cells[1]);
tables.cells[2].merge(tables.cells[4]);
tables.columns[4].remove();
tables.columns[3].remove();This script does what your steps specify.
-
August 30, 2016 at 2:08 pm #87933Martin KoreckýMember
Thanks for your help, I will try it asap.
-
August 30, 2016 at 2:46 pm #87934Martin KoreckýMember
Works like a charm, thank you very much for saving me hours of terrible work! I just made one small mini-tweak, because it merged all first two rows togehter, I think this happens because after the first merge, numbering of the cells is shifted.
my edit of the second merge:
…
tables.cells[0].merge(tables.cells[1]);
tables.cells[1].merge(tables.cells[3]);
…(or maybe using them in your way, just in oposite order would also help)
Thanks a lot!
-
August 31, 2016 at 8:53 am #87946Matt IsaacParticipant
Yeah, i didn’t even think about the cells shifting with the merge.
-
-
AuthorPosts
- You must be logged in to reply to this topic.