How to get the documents name in Numbers with Apple Script?

Hi there,

Here is a minimum example of a script that worked fine some weeks ago. But now it produces an error message: number -1728.


tell application "Numbers"
	activate
	set doc_name to the name of the front document
end tell


error "„System Events“ hat einen Fehler erhalten: „document 1 of
process \"Numbers\"“ kann nicht gelesen werden." number -1728
from document 1 of process "Numbers"


Translation: „System Events“ got an error: „document 1 of process \"Numbers\"“ can not be read.


I think the new version of Numbers causes this error. But I am not sure. What is reason for it?


Any ideas?

Posted on Oct 7, 2019 03:30 PM

Reply
Question marked as Top-ranking reply

Posted on Oct 7, 2019 03:53 PM

Your script is working well here when I run it from Script Editor. Are you running it from Script Editor or in some other way?


Things to try (in Mojave; don't know yet about Catalina):


  1. Make sure Script Editor and Numbers are both listed and checked at System Preferences > Security & Privacy > Privacy > Accessibility.
  2. Closing Numbers and reopening
  3. Restarting your Mac.
  4. At System Preferences > Language & Region change your region temporarily to United States and trying running the script.


SG


2 replies
Question marked as Top-ranking reply

Oct 7, 2019 03:53 PM in response to Uhlhorn

Your script is working well here when I run it from Script Editor. Are you running it from Script Editor or in some other way?


Things to try (in Mojave; don't know yet about Catalina):


  1. Make sure Script Editor and Numbers are both listed and checked at System Preferences > Security & Privacy > Privacy > Accessibility.
  2. Closing Numbers and reopening
  3. Restarting your Mac.
  4. At System Preferences > Language & Region change your region temporarily to United States and trying running the script.


SG


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to get the documents name in Numbers with Apple Script?

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