How do you select a table row by row number?

I’ve tried things like the following:

set selected data rows to data row 1 of table view 1 of scroll view 1 of window 1

I get the error message:

“Can’t make <> into type reference (-1700)”

Do I need to refer to the data source perhaps? (I have a hard time determining the difference between the data source and a reference to the table view) I’ve tried everything I could think of or glean from similar posts without any luck.

Hi,

selected data rows has no reference, actually the correct reference is


set selected data row of table view 1 of scroll view 1 of window 1 to data row 1 of table view 1 of scroll view 1 of window 1

but using a tell block is smarter

tell table view 1 of scroll view 1 of window 1
	set selected data row to data row 1
end tell

Note: selected data rows expects a list, there’s also a singular version

Thank you StefanK for pointing out my omission. Experimenting with your suggested script, I further found it necessary to trim my reference to the row to a bare number. So this worked:

set selected row of table view 1 of scroll view 1 of window 1 to 1 

It all seems so obvious to me now thanks to your tip :slight_smile: