Skip to main content
dublove
Legend
December 22, 2024
Question

Script request please: merge the rows where the cursor is and fill in Cell with the word "Continue"

  • December 22, 2024
  • 2 replies
  • 605 views

Hello, please.
What should I write in the next sentence?

 

merge the rows where the cursor is and fill in Cell with the word "Continue"

No need to select the  the row.

 

thank you~

This topic has been closed for replies.

2 replies

Robert at ID-Tasker
Legend
December 23, 2024

@dublove 

 

If you can first select cells to be merged - doesn't matter if it's a row or a few cells - this will work:

app.selection[0].merge();

 But it won't merge whole rows - if you select a few cells in the middle.

 

This, will only merge first selected row of the selection:

app.selection[0].parentRow.merge();

keeping the rest of the cells selected:

 

 

dublove
dubloveAuthor
Legend
December 23, 2024

I expressed myself wrongly.
I want to add a new row at the top of the table, and  then merge the whole row, and then apply the style and set row height.

Robert at ID-Tasker
Legend
December 23, 2024
quote

I expressed myself wrongly.
I want to add a new row at the top of the table, and  then merge the whole row, and then apply the style and set row height.


By @dublove

 

Yes, I know, I've just posted a more simplified version of the @Eugene Tyson's code - without error handling.

 

Community Expert
December 23, 2024

Here you go - if you need something more specific just let us know

 

// Ensure a document is open and a text insertion point is selected
if (app.documents.length > 0 && app.selection.length > 0 && app.selection[0].constructor.name === "InsertionPoint") {
    var cursor = app.selection[0];
    var parentCell = cursor.parent;

    // Check if the cursor is within a table cell
    if (parentCell.constructor.name === "Cell") {
        try {
            var parentRow = parentCell.parentRow;

            // Merge all cells in the parent row using the first and last cells of the row
            var firstCell = parentRow.cells[0];
            var lastCell = parentRow.cells[parentRow.cells.length - 1];
            firstCell.merge(lastCell);

            // Set the content of the merged cell to "Continue"
            firstCell.contents = "Continue";

            alert("Row merged and cell updated with 'Continue'.");
        } catch (e) {
            alert("An error occurred: " + e.message);
        }
    } else {
        alert("Please place the cursor inside a table cell.");
    }
} else {
    alert("Please open a document and place the cursor inside a table cell.");
}

 

dublove
dubloveAuthor
Legend
December 23, 2024

It works. It's great.
Thank you very much.

Here's what I initially thought:
1. select the header row of the table (could be 1 or 2 rows)
2. add 1 new row before the selected row.
3. merge the newly created rows and put in the “continue” character
4. for the new line to apply the “cont” cell style
5. set the new line of the exact row height of 5mm.
6. will be “initially selected rows and new rows” converted to table header rows.
7. Set to skip the first page of the table header row.

 

I originally asked a poster.

https://community.adobe.com/t5/indesign-discussions/is-there-a-script-to-automatically-continue-rows-of-a-table/m-p/15053884#M603001 
Am I being greedy?
I feel a little guilty

 

Community Expert
December 23, 2024

If you just want to have a Continue row you don't need to do anything like that - if it's just for new frames and you want to show it's continuing

 

 The only thing to be aware of is the first frame you have to insert the header rows as text - so if you want to manipulate the headers of row 2/3 you need to copy the text from 2nd frame back to the original frame. 

 

As I highlight here - this text needs to be changed manually.

But you get your continuation rows.

 

 

No idea why you opened a new thread for the same thing - confuses things and makes it harder to track this conversation in the future.