Copy link to clipboard
Copied
I wrote a simple script to add "." period to all the first column of my tables after the number. I am bringing in data from excel that does not have a "." after the number. Here is the script:
var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
var myColumns = app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().getElements();
for(i=0; i<myTable.length; i++)
for(t=0; t<myColumns.length; t++)
{
myTable.columns[0].cells
}
This script works the way I want it to. It adds a period after the content that is already in the cell.
Here is my question, in case I have other tables in my document later that I do not want to add the "." to, how would I modify this script to apply it only to a selected table or column?
I know there is "app.selection" but I'm not sure how to use it correctly.
For a bonus, how do I undo the script all at once? if I use the undo feature (ctrl z), it undoes one row at a time. The reason I might need it is if i accidentally run the script twice, i end up with two periods. I cand do a find/change but was wondering how to write a script that would fix the error.
Thanks
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This is the Code I ended up with from reading on this site https://indesignsecrets.com/tackling-tables-through-scripting.php
var myTable = app.selection[0].tables.everyItem().getElements();
var myColumns = app.selection[0].tables.everyItem().rows.everyItem().getElements();
for(i=0; i<myTable.length; i++)
for(t=0; t<myColumns.length; t++)
{
myTable.columns[0].cells
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more