Legend
December 26, 2024
Question
Problems encountered: Use a script to get the current mouse-selected rows and repeat them.
- December 26, 2024
- 3 replies
- 878 views
Hello, everyone. Hello @Peter Kahrel.
I Use a script to get the current mouse-selected rows and repeat them.
I Saw a posting above on "creativepro.com" , at the bottom of the page, where Peter Kahrel gave a solution at the end.
I mimicked one and for some reason it prompted an error.
https://creativepro.com/topic/get-selected-table-rows-with-extendscript/
Help me look at it.
Thank you very much.
Below is the code I cobbled together. There's also an attachment.
var cell = app.selection[0].parent.parentRow.cells[0];
var myTable = cell.parent.parent;
var selectedRows = myTable.rows.itemByRange(cell,myTable.cells[-1]).select();
//var myTable = cell.parent
//firstRow = myTable.rows[0];
if (firstRow.rowType !== RowTypes.HEADER_ROW)
{
dupeTopRow(myTable);
myTable.rows.add(LocationOptions.BEFORE, selectedRows);
/**
* duplicate the first row af a myTable
* @ param the myTable
* @ return void
*/
function dupeTopRow(t){
var newRow = t.rows.add(LocationOptions.BEFORE, t.selectedRows);
var newCell = newRow.cells
var lr = t.rows[1].cells
for (var i = 0; i < newCell.length; i++){
newCell[i].properties = lr[i].properties;
};
}
}
else{
alert("header exist")
exit ();
}

