• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scripting Numbers Just a Little
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Numbers Just a Little


  • Subject: Re: Scripting Numbers Just a Little
  • From: Yvan KOENIG <email@hidden>
  • Date: Tue, 07 Feb 2017 19:20:46 +0100


Le 7 févr. 2017 à 03:30, Christopher Stone <email@hidden> a écrit :

Hey Folks,

I've always hated Apple's Numbers and preferred Microsoft Excel.

But – I needed to script a solution for someone in Numbers and have been fiddling with it over the last couple of days.  I think it's improved enough that I no longer hate it, but I don't think I'll prefer it to Excel anytime soon.

That said – I cannot for the life of me figure out how to select a cell in table 1 of document 1 with just the keyboard.

This is never a problem in Excel – there is always a selection – and Ctrl (or Cmd) + Home will get you to row 1 cell 1 in a hurry.

Perhaps someone knows how to do this in Numbers, but I went through all the keyboard shortcuts in the help and couldn't find a way.

This was driving me batty a few hours ago, so I wrote a script to select the first row of table 1 (or alternatively the first cell of that first row).

After giving it a keyboard shortcut with FastScripts I'm in a much better mood.  :)

--
Best Regards,
Chris

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/02/06 20:00
# dMod: 2017/02/06 20:17
# Appl: Numbers
# Task: Select Cell 1 or Row 1 of Table 1
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Numbers, @Select, @Cell, @Table
----------------------------------------------------------------

tell application "Numbers"
   if document 1 exists then
      tell document 1
         tell active sheet
            if table 1 exists then
               tell table 1
                  # Select first cell of first row of table 1:
                  set selection range to cell 1 of row 1
                  # Select first row of table 1:
                  # set selection range to row 1
               end tell
            end if
         end tell
      end tell
   end if
end tell

----------------------------------------------------------------

In Numbers we can't guarantee that something is selected in a table because a sheet may contain different  objects : tables of course but also text boxes, pictures, charts.

Below is a short script allowing us to navigate between tables.
If there is nothing selected in a table, it selects cell A1 of table 1
If there is something selected in a table, it jumps to cell A1 of the next table in the list of tables.

Just for info, when an item is selected in a table numerous shortcuts are available to navigate in the table.


tell application "Numbers"
if document 1 exists then
tell document 1 to tell active sheet
set theTables to every table
try
set currentTable to first table whose selection range's class is range
on error errMsg number errNbr
if errNbr = -1719 then
set currentTable to false
else
error errMsg number errNbr
end if
end try


if currentTable is false then
set newIndex to 1
else
set currentIndex to 0
repeat with aTable in theTables
set currentIndex to currentIndex + 1
if contents of aTable is currentTable then
set newIndex to currentIndex + 1
if newIndex > (count theTables) then set newIndex to 1
exit repeat
end if
end repeat
end if


tell (item newIndex of theTables)
set selection range to range "A1"
end tell
end tell
end if # document 1 exists
end tell # Numbers

Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) mardi 7 février 2017 19:20:21


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Scripting Numbers Just a Little (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: InDesign problems placing items on spreads
  • Next by Date: Re: Scripting Numbers a Little More – Extracting Data into an Array
  • Previous by thread: Scripting Numbers Just a Little
  • Next by thread: Scripting Numbers a Little More – Extracting Data into an Array
  • Index(es):
    • Date
    • Thread