Has anyone been able to create a URL link directly to a Numbers sheet?

A URL to open the file is simple. I was wondering if someone had figured out how to link to a sheet directly, a link which I would insert into a KM open URL action.
thank you

I don't think it's possible, other than within Numbers, where it's easy to create a link directly to another sheet. But you can't take that link out of Numbers in any way.

The exception is collaboration: If you use the Share link, you can create a link that works for anyone that goes directly to a sheet. But I don't think that's what you want, right?

-rob.

1 Like

thank you very much !. I don't think that share would work for me. I would have to start by moving all files to iCloud.

Numbers is AppleScript'able.

Try:

tell application "Numbers"
	tell document 1
		set active sheet to sheet 2
	end tell
end tell

You can query the active sheets looking for one with a specific name, etc...

1 Like

@ronald asked for something he could use in an Open URL action, which an AppleScript can't really do. And while I'm no AppleScript expert (far from it), the following script should work:

tell application "Numbers"
	activate
	set targetWorkbook to open "/full/path to the/workbook.numbers"
	tell targetWorkbook
		set targetSheet to sheet "Name of the sheet"
		set active sheet to targetSheet
	end tell
end tell

I wrote it myself first, in a simpler form (activate numbers, open workbook, tell the workbook to open the sheet), but it didn't work—the book opened, but not the sheet. ChatGPT offered the above version, which sets a targetWorkbook variable, and this gets the job done.

But you can't put that in an Open URL action. However, if the more general objective is to open a given sheet in a given workbook via Keyboard Maestro, then the above should work. (The OS will ask you to give permission to Keyboard Maestro to control Numbers the first time you run this.)

-rob.

2 Likes

To be fair, the OP did say that they were triggering the Open URL action from a macro, so.. I guess I was assuming that they could run the applescript after the URL action and a 'wait for application'.. of course, doing it all in one step (like you have) is optimal.

2 Likes

Yea, I should have gone back to the question we should always ask first: What are you trying to accomplish, as opposed to what Keyboard Maestro thing do you need help with. I would assume the same as you, reading it again now: An AppleScript should accomplish the implied objective of opening a specific Numbers sheet from Keyboard Maestro.

-rob.

Thank you @johns for suggesting AppleScript. It is indeed the solution.
Thank you @griffman for an AppleScript that works perfectly.

I had tried to derive a workable AppleScript from different scripts on the Internet but it failed.

@griffman @johns
It's me again. A philosophical question.
For common apps like Numbers and many more, why isn't there an extensive library of AppleScripts widely available. It's crazy that so many people must be working individually on the same problem. Since such libraries don't exist, there must be some rationale that I do not understand.

I assume because nobody has felt like there's any money to be made in doing so? Curating such a list would require a server, some back-end system to accept, format, and post the scripts, etc. That takes time and resources, and as useful as it might be, most people wouldn't be willing to pay for it. And without financial support, now you've got a hobby, one that takes a lot of time with very little reward :).

You can see all the scripts posted on GitHub, but that's about the only "repository" of scripts I was able to find.

I agree, it's a great idea (as would repositories for Keyboard Maestro macros and any number of things for other apps that lots of people use). I just don't see it happening :(.

-rob.

1 Like

When I wrote my post I was thinking about Github which I thought was the rule and you explain very well why it's the exception

Hey Folks :wave:

Stumped on this morning I as thinking about how I maybe could help.

Rob (@griffman) - as I just read your last post about having GitHub Repos and the fact that there is often the time as a factor why nobody is creating such resources - it made me smile …

@ronald your post about missing resources made me smile, too …

My Automation Journey began switching to the Mac completely from windows many years ago.

I also had these thoughts very often why there are no resources and started a project and was searching for about tree to four years for a solution on how I could build my own system for something like this inkluding a Database system. And I found the best solution for me collecting any resources I could have and manage that using DEVONthink.

Why I am talking about this is the funny fact that my plans are to build a GitHub Repo pointing to such resources … I don’t know really when I can start to launch this Repository… but I thought that telling you there is one person who plans thing this on this forum.

I am still learning many things I need for this Project - therefor please be patient with me - but it will happen.

Wish you all a great day :sunglasses:

Greetings from Germany

Tobias

FWIW, the app "Script Debugger" really helps when trying to inspect what is possible when scripting an app. It's the 'go to' for AppleScript devs (IMO).

It helps in a few ways:

  • Integrated dictionaries for all apps
  • Inspectable results from a script -- lets you inspect variables and drill in to the objects and really see what's possible!
  • Robust debugging
2 Likes

No lack of rationale – just no business model.

1 Like

Just an alternative suggestion if someone wanted to open the document and choose the sheet to navigate to…

property numberDocPath : "/Users/apollox/Downloads/attendance.numbers"  -- Select the doc in the Finder and press _Option-Command-C_ to copy the POSIX path.

tell application "Numbers"
	activate
	set sheetList to name of (sheets of (open numberDocPath))
	if (count sheetList) > 1 then
		set chosenSheet to (item 1 of (choose from list sheetList without empty selection allowed and multiple selections allowed)) as string
		tell document 1 to set active sheet to sheet chosenSheet
	end if
end tell
2 Likes

thank you !

1 Like

hello @griffman , @ComplexPoint @Nr.5-need_input @johns @DEVONtech_Jim
The script works very well to link to a numbers sheet.
Another issue I have is that when a cell contains too much text and distorts the Numbers table, I would like to put that text in a text box which is very convenient.
Now my problem is to create a link from a cell in the Numbers table to a text box. I googled the problem and got nothing short of putting each text box in a different sheet which is not realistic.
Would you have any idea ?
thank you very much

Hello @ronald :wave:

Here is what I would try - if it is a thing that can be done.

I would combine the Numbers Document with a dedicated Pages Document. Since Pages is also very Scriptable this should be possible in theory. But even if this can be done the code might not be very easy. Besides that I‘ve never done anything like this….

Greetings from Germany

Tobias

That sounds like a Numbers question, but I'm an Excel person, not a Numbers person—I know just enough about Numbers to get by.

-rob.

Also not a Numbers user, but I don't think you can link a text box to a cell. A couple of other options spring to mind, though:

  1. You can make another 1x1 table on the same sheet and link that single cell to the one whose contents you wish to display. Position and format it how you want and then lock it so it can't be selected -- its contents will still update as the original cell does
  2. You might be able to use AS to replace the contents of a text box with the current contents of the cell you want to reference. No auto-updates, you'll have to run a script yourself, and it could get tricky if you want more than one text box per sheet

If you do want to go the AS route, this should be enough to get you started:

tell application "Numbers"
	tell document 1
		tell sheet 1
			set object text of text item 1 to (get value of cell "B2" of table 1)
		end tell
	end tell
end tell
2 Likes