Highlighted

Strange behavior using table.cells.itemByName("c:r")

Adobe Community Professional ,
May 28, 2020

Copy link to clipboard

Copied

I'm doing some maneuvering through tables, and running into a bit of a conundrum using the cells.itemByName("colIndex:rowIndex") matrix to select my preferred cell. 

 

 

 

var cell_ref = '"' + new_column.toString() + ":" + new_row.toString() + '"';
$.writeln(cell_ref); //returns "2:3"
THE_TABLE_OBJECT.cells.itemByName(cell_ref).select(); //selects column 0, row 3

 

Very odd behavior. I am able to work around with: 

 

THE_TABLE_OBJECT.rows[new_row].cells[new_column].select();

 

 

If I test on the same table with just a one-line code of: 

 

THE_TABLE_OBJECT.cells.itemByName("2:3").select();

 

it works fine. 

Could it have something to do with how converting new_column.toString() is behaving? It shows as "2:3" in the console, but maybe something fishy is going on there? I've tested the new_column integer and it shows as 2 with a Number constructor.

 

Anyone else have any experience with this bug? Not a huge deal I suppose since there's a workaround; just curious. 

 

 

Adobe Community Professional
Correct answer by Sunil Yadav | Adobe Community Professional

Hi brianp311,

Why are you putting those double quotation marks?

 

Instead you can try like this :

///////////////////////////////////////////////////

var cell_ref = new_column + ":" + new_row;
$.writeln(cell_ref);
app.documents[0].textFrames[0].tables[0].cells.itemByName(cell_ref).select();

///////////////////////////////////////////////////

 

Because Cells.itemByName(Argument)== This methods expects String (Digit:Digit) but in your code you are giving Double quotation as well and that is not a digit that is the reason why column index is  not working, but after color (:) there is a digit for row, so that one is working fine with index.

 

Best

Sunil

TOPICS
Scripting

Views

351

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

Strange behavior using table.cells.itemByName("c:r")

Adobe Community Professional ,
May 28, 2020

Copy link to clipboard

Copied

I'm doing some maneuvering through tables, and running into a bit of a conundrum using the cells.itemByName("colIndex:rowIndex") matrix to select my preferred cell. 

 

 

 

var cell_ref = '"' + new_column.toString() + ":" + new_row.toString() + '"';
$.writeln(cell_ref); //returns "2:3"
THE_TABLE_OBJECT.cells.itemByName(cell_ref).select(); //selects column 0, row 3

 

Very odd behavior. I am able to work around with: 

 

THE_TABLE_OBJECT.rows[new_row].cells[new_column].select();

 

 

If I test on the same table with just a one-line code of: 

 

THE_TABLE_OBJECT.cells.itemByName("2:3").select();

 

it works fine. 

Could it have something to do with how converting new_column.toString() is behaving? It shows as "2:3" in the console, but maybe something fishy is going on there? I've tested the new_column integer and it shows as 2 with a Number constructor.

 

Anyone else have any experience with this bug? Not a huge deal I suppose since there's a workaround; just curious. 

 

 

Adobe Community Professional
Correct answer by Sunil Yadav | Adobe Community Professional

Hi brianp311,

Why are you putting those double quotation marks?

 

Instead you can try like this :

///////////////////////////////////////////////////

var cell_ref = new_column + ":" + new_row;
$.writeln(cell_ref);
app.documents[0].textFrames[0].tables[0].cells.itemByName(cell_ref).select();

///////////////////////////////////////////////////

 

Because Cells.itemByName(Argument)== This methods expects String (Digit:Digit) but in your code you are giving Double quotation as well and that is not a digit that is the reason why column index is  not working, but after color (:) there is a digit for row, so that one is working fine with index.

 

Best

Sunil

TOPICS
Scripting

Views

352

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
May 28, 2020 0
Adobe Community Professional ,
May 29, 2020

Copy link to clipboard

Copied

Hi brianp311,

Why are you putting those double quotation marks?

 

Instead you can try like this :

///////////////////////////////////////////////////

var cell_ref = new_column + ":" + new_row;
$.writeln(cell_ref);
app.documents[0].textFrames[0].tables[0].cells.itemByName(cell_ref).select();

///////////////////////////////////////////////////

 

Because Cells.itemByName(Argument)== This methods expects String (Digit:Digit) but in your code you are giving Double quotation as well and that is not a digit that is the reason why column index is  not working, but after color (:) there is a digit for row, so that one is working fine with index.

 

Best

Sunil

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...
May 29, 2020 0
Adobe Community Professional ,
May 29, 2020

Copy link to clipboard

Copied

D'oh, of course. Long story short, converting someone else's Applescript to jsx and got lost in translation. Thanks Sunil.

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...
May 29, 2020 0