Using scripts for advanced table sculpting – help needed

Learn / Forums / General InDesign Topics / Using scripts for advanced table sculpting – help needed

Viewing 4 reply threads
  • Author
    Posts
    • #87918

      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 them

      this 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.

    • #87932
      Matt Isaac
      Participant

      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.

    • #87933

      Thanks for your help, I will try it asap.

    • #87934

      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!

    • #87946
      Matt Isaac
      Participant

      Yeah, i didn’t even think about the cells shifting with the merge.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.
>