Saving a Numbers Document with Name Taken From a Cell On The Sheet

Ok, this is weird, and admittedly, I'm no AppleScript expert, but I have had a working AppleScript Workflow running as a service in Numbers, but when I moved it from my MBP running Sequoia 15.71 to an Apple Studio running the current version of Tahoe it worked for a short period then started generating an error.


Basically, the Service (AppleScript) grabs the name from a cell that exists on a table on the second sheet and saves it in a folder on the desktop labeled: "Expense Reports". It works flawlessly on the MBP. On the Mac Studio it throws this error:


"The document "untitled.numbers" could not be exported as "Henry Smith". You don't have permission. To view or change permissions, select the item in the Finder and choose File > Get Info"


Then it throws some other error afterwards about "Apple EventHandler failed. . . "


There's probably a "best practice" step I'm missing in my script. I'm just wondering if there's a way to explicitly grant the necessary access to the save location within the script itself to avoid the error, or perhaps there's something incorrect within the code itself.


The code that is working on the MBP is:


on run {input, parameters}


tell application "Numbers"


tell the front document


set active sheet to sheet 2


tell the active sheet


tell the first table -- Where the Name exists


set cellValue to the value of cell "B3" -- Get the name of the person on the report


if cellValue is not missing value then


display dialog “Expense Report For: " & cellValue & " Created!”


tell application "Numbers"


-- Referencing the front document in Numbers App


set theDocument to the front document


                         -- Access the second sheet and first table 


tell the second sheet of theDocument


tell the first table -- Where the name should exist


                                  set cellValue to the value of cell “B3”


                                   -- Get the name of the person on the report


end tell


end tell


-- Define the save location and filename 


set savePath to ("Macintosh HD:Users:MAIN_WORK:Desktop:Expense Reports:" as text) & cellValue & ".numbers"


-- Save the document with the derived filename


save theDocument in file savePath


end tell


else


display dialog "Cannot Save! No member name present!"


end if


end tell


end tell


end tell


end tell


return input


end run


I'd say the script is simple enough, and if anyone here can help me out, that would be great. Feel free to clean it up hopefully fix the errors.


Thanks in advance!

Posted on Nov 1, 2025 6:22 AM

Reply
Question marked as Top-ranking reply

Posted on Nov 1, 2025 8:37 AM


Ed M. wrote:

I thought there might be something I could add to the script that would allow access so the file can be saved in that location.

EDIT: I think I'm going to try granting the Numpers.app Full Disk Access.



With each new macOS release, security seems to get more and more fiddly...


While you're at it, under Privacy & Security you might also try giving Script Editor full disk access if you haven't done so already, and Automator too (in case that is the problem with Services).


If that doesn't work for this situation then you might want to go back and remove full disk access just so you don't create unintended problems in the future when you're doing something else.


Also in Finder go to Macintosh HD:Users:MAIN_WORK:Desktop:Expense Reports:, right-click, and make sure Sharing and Permissions is set to Read & Write.


Seemingly unrelated: the fact that the error message refers to "untitled.numbers" suggests that the script was not successful in picking up the name from the cell.


SG

3 replies
Question marked as Top-ranking reply

Nov 1, 2025 8:37 AM in response to Ed M.


Ed M. wrote:

I thought there might be something I could add to the script that would allow access so the file can be saved in that location.

EDIT: I think I'm going to try granting the Numpers.app Full Disk Access.



With each new macOS release, security seems to get more and more fiddly...


While you're at it, under Privacy & Security you might also try giving Script Editor full disk access if you haven't done so already, and Automator too (in case that is the problem with Services).


If that doesn't work for this situation then you might want to go back and remove full disk access just so you don't create unintended problems in the future when you're doing something else.


Also in Finder go to Macintosh HD:Users:MAIN_WORK:Desktop:Expense Reports:, right-click, and make sure Sharing and Permissions is set to Read & Write.


Seemingly unrelated: the fact that the error message refers to "untitled.numbers" suggests that the script was not successful in picking up the name from the cell.


SG

Saving a Numbers Document with Name Taken From a Cell On The Sheet

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