Highlighted

To be able to delete a column in a table with a script

New Here ,
Jul 27, 2020

Copy link to clipboard

Copied

Does anyone have a script that will enable me to delete a coloumn fron a table, i would like to be able to enter the text that its in the cell of the top row and then it delete that coloum.

 

Thanks

TOPICS
How to, Scripting

Views

34

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

To be able to delete a column in a table with a script

New Here ,
Jul 27, 2020

Copy link to clipboard

Copied

Does anyone have a script that will enable me to delete a coloumn fron a table, i would like to be able to enter the text that its in the cell of the top row and then it delete that coloum.

 

Thanks

TOPICS
How to, Scripting

Views

35

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 27, 2020 0
Adobe Community Professional ,
Jul 28, 2020

Copy link to clipboard

Copied

Try the following, make a selection of the textframe that has the table, it will search only on the first table of this textframe. You can change the value of the variable text to the value you want to search.

var text = "sample"
var tb = app.selection[0].tables[0]
var firstRow = tb.rows[0].cells.everyItem().contents
for(var i = 0; i < firstRow.length; i++)
	if(firstRow[i] == text)
	{
		tb.columns[i].remove()
		break;
	}

This has not been tested in tables with merged cells etc, the code should give you idea enough to make the changes as needed by your workflow

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 28, 2020 0
Adobe Community Professional ,
Jul 28, 2020

Copy link to clipboard

Copied

If you want to have a user interface, you'd change the first line of Manan's script to: 

 

var text = prompt("text of cell to delete","");

 

Whatever you type in would be case sensitive.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 28, 2020 0