pythoniworksourceforge-appscriptpy-appscript

How to set selection for a table in Numbers?


How do you set the selection for a table in Numbers using py-appscript?

This seems like it should be really simple to do but the solution is frustratingly evasive. I can get the current selection:

 current_table.selection_range

and I can get its cells:

  current_table.selection_range.cells()

but trying to set() either of them gets an angry appscript error.


Solution

  • Looks like something like this works:

    >>> current_table.selection_range.set(to=current_table.ranges[u'B3:C10'])
    

    Note, looking at Number's script dictionary in AppleScript Editor or with ASDictionary, the property selection_range is defined as class range. So that's a clue that you need to come up with a reference of type range to set it.