Skip to main content
Known Participant
May 12, 2023
Answered

table: copy and paste the first column of the content

  • May 12, 2023
  • 3 replies
  • 1456 views

Dear all,

     Actually i have eight column in a table.

     First: I need to create a column[last] in existing table.

     Second: copy the content of first column and paste it in last column[i.e.,created column] using scripting

 

 

Thanks in advance.

This topic has been closed for replies.
Correct answer nicosh

Hi @John_devs 

With a selected table try this

//This script copies first column after the last column in a selected table

//Select table
var selection = app.selection[0];
//First column of selected table
var firstColumn = selection.columns[0];
//increase table with one column
selection.columnCount = selection.columns.length + 1;

firstColumn.select();
app.copy();
selection.columns[-1].select();
app.paste();

3 replies

nicoshCorrect answer
Inspiring
May 13, 2023

Hi @John_devs 

With a selected table try this

//This script copies first column after the last column in a selected table

//Select table
var selection = app.selection[0];
//First column of selected table
var firstColumn = selection.columns[0];
//increase table with one column
selection.columnCount = selection.columns.length + 1;

firstColumn.select();
app.copy();
selection.columns[-1].select();
app.paste();
John_devsAuthor
Known Participant
May 15, 2023

Hi @nicosh ,

thanks for the support

but i am getting "Object does not support 'columns' error"

could you assist me to fix this

Inspiring
May 15, 2023

Hi @John_devs 

I tested in a simple table with 10 cols and 12 rows with merged cells in rows 9 and 10 of first column and works fine for me.

Can you upload your indd file to test it?

Remember that you have to select the table.

Community Expert
May 12, 2023

Hi @John_devs ,

what properties in the copied over column should be maintained?

Does it work for you if you do this without a script?

What are your steps?

 

And: how many tables do you have where this workflow is necessary?

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Eric Dumas
Community Expert
Community Expert
May 12, 2023

Hi,

Can you describe why scripting is needed? Usually a import (Place) from Word/Excel/CSV (data merge) can work really well.