AppleScript to reveal a Numbers table which is off screen

I have an AppleScript which manages a large Numbers document.  A sheet in this document will have multiple tables, and sometimes I need to manually interact with one of them.  The script includes a display dialog which lists the instructions to carry out the interaction.


My problem is that the display dialog appears to prevent manual scrolling sometimes needed to reveal the table requiring attention. How can I arrange for the table to be displayed before invoking the display dialog?


I've tried simply setting a cell value in the off-screen table

tell table oldTable to set value of cell 3 to "OXO"

which sets the value but doesn't scroll the sheet to reveal the table.


I’ve tried to interact with the  sheet tab’s table menu  with


activate "Numbers"
tell application "System Events"
	perform action "AXShowMenu" of radio button “mySheet” of tab group 1 of scroll area 1 of window 1 of process "Numbers"
end tell


which brings up a menu of items including all  the table names. However I can’t see how to make AppleScript interact with those menu items.   Can anyone help me out please?


(Current workaround is to manually  move the display dialog away from the Numbers sheet.)

MacBook Pro 16″, macOS 15.5

Posted on Jun 29, 2025 4:10 AM

Reply
8 replies
Sort By: 

Jun 29, 2025 5:01 AM in response to jbh2

If I understand correctly what you are trying to do then you can move the focus to your target table with something like this:


tell front document of application "Numbers"
	tell active sheet
		tell table myTargetTableName to set selection range to cell 1
	end tell
end tell



This is similar to your original idea of setting the value of a cell in the table. But instead of setting the value of a cell (which doesn't "scroll") you can set the selection range to a particular cell in the target table.


SG

Reply

Jun 29, 2025 8:43 PM in response to jbh2

Use a cell other than cell 1. I don't know what is up with cell A1 that it won't go to the table when you use that cell. If you use cell 1 or "A1", hitting an arrow key will take you there. You can make that part of the script.


I recommend using a body cell. I don't like how it scrolls the table when a header cell is used vs a body cell, some of the rows end up scrolled under the header if the table is too big to entirely fit in the window.




activate application "Numbers"
tell front document of application "Numbers"
	tell active sheet
		tell table "Table 1" to set selection range to cell "B2"
	end tell
end tell

Reply

Jun 29, 2025 7:31 PM in response to SGIII

Thanks for responding SG. Unfortunately, as with the value setting strategy, the sheet is not "scrolling" to display the selected cell in the window.

I wondered whether the size/complexity of my document was somehow preventing scrolling so have tested on a simple doc with just two tables. Just to be clear, the target table is positioned on the sheet so as to be outside the Numbers window. Same result. -JBH

Reply

Jun 29, 2025 8:46 PM in response to jbh2

jbh2 wrote:

the sheet is not "scrolling" to display the selected cell in the window.
I wondered whether the size/complexity of my document was somehow preventing scrolling so have tested on a simple doc with just two tables. Just to be clear, the target table is positioned on the sheet so as to be outside the Numbers window.


Perhaps try again? Definitely works here when the target table is out of sight to the right or bottom.


Perhaps you could post the exact script you are using and a screenshot of the tables.


Also, keep in mind that you can always go up to the sheet name "tab" at the top and choose the table you want from the dropdown that appears there. That will take you immediately to the table, without the need for AppleScript.


SG

Reply

Jun 29, 2025 9:56 PM in response to SGIII

Tried again (Good suggestion SG) and Yes it does work but it seems only if the specified cell is a body cell as Badunit suggested.


Much easier than scripting the dropdown menu which was driving me bonkers before you guys sorted me out.

Thank you both.

Reply

Jun 30, 2025 9:11 AM in response to jbh2

jbh2 wrote:

it does work but it seems only if the specified cell is a body cell

Much easier than scripting the dropdown menu


I see that cell 1 does not work if the target table has both a Header Row and a Header Column. Otherwise, it works fine on my machine, e.g. when the first column is not a Header Column. Probably a small bug.


The dropdown menu would be tough to script. It does make it easy to navigate to a table without using a script.


SG




Reply

Jun 30, 2025 2:02 PM in response to Badunit

> While we are on this subject, I thought "activate" would unminimize a running app that was minimized to the dock


This changed in Catalina (IIRC), at the OS level, not specifically AppleScript.


Pre-Catalina, activating an application (whether via AppleScript, clicking the app icon in the dock, Command-Tab, etc.) would automatically un-miniturize its windows. In Catalina and later, the activation no longer expands miniaturized windows. So it's the OS that changed, not AppleScript, per se.

Reply

AppleScript to reveal a Numbers table which is off screen

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.