Script to merge all cells in first row of a table.

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Script to merge all cells in first row of a table.

Viewing 3 reply threads
  • Author
    Posts
    • #76255
      Bryan Fowler
      Member

      I’ve got a number of documents that have 100’s of tables. Most of the tables are 5 columns and can be 2 to 50 rows in length. I need to merge all the cells of the first row only of each table.

      I’m new to scripting and this is driving me crazy as it seems so simple.

    • #76305
      Loic Aigon
      Member

      Would that be the really first row or the first row after the table header ?

    • #76308
      Bryan Fowler
      Member

      Yeah, I ran into that problem. Some of the tables had the first row as a header and some of them did not have a header but did have the 1st body row a different color and used like a header.

      I ended up using the following along with Jong’s poser https://creativepro.com/tackling-tables-through-scripting.php to merge the first body row and it worked great.

      table.cells.item(0).merge(table.rows.item(0).cells.item(-1));

      But the tables with headers caused the script not to work. I found some code that allowed me to convert body rows to header rows but it wouldn’t work in reverse so I did it the harder way. Only the first 3 pages of the 100 page doc had actual header so I moved them to a new document, ran the script, then merged the documents back together.

      table.rows.item(0).rowType = RowTypes.bodyRow;

      Actually, it does work but only when I select the table. I get an error when I use it with Jong’s code in that URL to do the entire document.

    • #76322
      Mark Jason
      Member

      I could not understand what you are talking about and what is your problem?

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