• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Expert ,
May 28, 2020 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. 

 

 

TOPICS
Scripting

Views

503

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
community guidelines

correct answers 1 Correct answer

Advocate , May 29, 2020 May 29, 2020

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 di

...

Votes

Translate

Translate
Advocate ,
May 29, 2020 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

Votes

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
community guidelines
Community Expert ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines