Is there a way to create a macro to list all the sheets in an apple numbers file?

One would think that this would be useful for many numbers users but no reference to a solution via google.
thanks in advance for your time and help

For example:

Sheet names in front Numbers document.kmmacros (1.9 KB)


Expand disclosure triangle to view JS source
const
    doc = Application("Numbers")
    .documents.at(0);

return doc.exists()
    ? doc.sheets.name()
      .join("\n")
    : "No document open in Numbers";
1 Like

Alternatively:

const
    doc = Application("Numbers")
    .documents.at(0);

return doc.exists()
    ? JSON.stringify(doc.sheets.name())
    : "No document open in Numbers";

(in a JavaScript for Automation Action, as above), defines a JSON list, accessible to both:

  • %JSONValue% tokens, and
  • For Each actions

in Keyboard Maestro.

1 Like

thanks very much @ComplexPoint !

My overall objective is to create a table of contents for numbers files.

The table of contents would simply be a table in a dedicated sheet (the first on the left labeled "TOC") which would contain a list of the sheets - which you solved.

The 2nd step is to convert each sheet name to a link to that sheet. My problem now is that I am unable to find the syntax and the macro actions to batch convert the list of sheet names to a list of links to those sheets.

I google "numbers sytax link to sheet "and found nothing which is strange.

Would you have any idea ?

thanks again very much

As always, you need to show:

  1. A sample input (zipped Numbers file) that we can experiment with, and
  2. a sample, or at least visual sketch, of the kind of output you that you want.

any macro or script is essentially a mapping from an input pattern to an output pattern.

Until the territory is shown, the map remains undefined.

1 Like

You are right and my apologies for a poorly formulated and documented post.

Numbers Test Table of Contents.numbers.zip (56.8 KB)

Screenshot (click to expand/collapse)

thank you

Doesn't look to me as if Sheet links within Numbers are based on a URL handler – certainly nothing that is immediately visible in NSPasteBoard when we copy sheet links.

i.e. not sure that that's feasible I'm afraid.

1 Like

very interesting. I never suspected that the links would be so complex.I will create all links manually. thanks a million !

Possibly worth experimenting with GUI scripting, starting here:

but that kind of route often leads to a fragile time-sink.

1 Like

I will have a look but I doubt that I have the intellectual abilities. thank you for giving it so much thought.