Apple Intelligence now features Image Playground, Genmoji, Writing Tools enhancements, seamless support for ChatGPT, and visual intelligence.

Apple Intelligence has also begun language expansion with localized English support for Australia, Canada, Ireland, New Zealand, South Africa, and the U.K. Learn more >

You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript and Numbers saving/exporting issue after updating to OS Sierra 10.12.2

Hi, I made an applescript that generates a new numbers file from scratch, saves it in .numbers format and then exports it to pdf on a separate folder. It worked flawlessly on OS Sierra 10.12.1, but after updating on dec 27 2016 to 10.12.2 it gives the following error:


The document “Untitled” could not be saved as “my_custom_file_name.numbers”. You don’t have permission.

To view or change permissions, select the item in the Finder and choose File > Get Info.


When I removed the .numbers format saving part of the script to just leave the pdf export section, there is no error (no file being saved as .numbers triggering it of course) but there is also no pdf being exported and does not show any error for that one)


This is the portion of the script that I use for the saving/export for your reference:

...

set the defaultDestinationFolder to (path to me) as string

set documentName to "my_custom_file_name"


set exportFileName to documentName & ".numbers" as string

set the targetFileHFSPath to (defaultDestinationFolder & "Numbers versions folder:" as string) & exportFileName

save front document in file targetFileHFSPath


set exportFileName to documentName & ".pdf" as string

set the targetFileHFSPath to (defaultDestinationFolder & "PDF versions folder:" as string) & exportFileName

export front document to file targetFileHFSPath as PDF

...


I think this is an issue of OS Sierra 10.12.2 as it worked well before it.


The numbers version is 4.0.5 (4052)


Any ideas for a work around, and how to report this to apple so they can fix it on a future release? (I already tried going to http://bugreport.apple.com/ but for some reason it does not recognize my apple ID...)


Thanks for your help in advance.

MacBook Pro with Retina display, macOS Sierra (10.12.2), Numbers v4.0.5 (4052)

Posted on Jan 9, 2017 5:18 PM

Reply
Question marked as Top-ranking reply

Posted on Feb 2, 2017 3:06 PM

Fix found! for anyone having this same issue, just add this before the save or export line:


close access (open for accessexportDocumentFile)

Thanks to bjh333 for pointing it out on another post.

And thanks to Yvan Koenig for figure it out (source): http://macscripter.net/viewtopic.php?pid=188721

10 replies
Question marked as Top-ranking reply

Feb 2, 2017 3:06 PM in response to International Traveler

Fix found! for anyone having this same issue, just add this before the save or export line:


close access (open for accessexportDocumentFile)

Thanks to bjh333 for pointing it out on another post.

And thanks to Yvan Koenig for figure it out (source): http://macscripter.net/viewtopic.php?pid=188721

Jan 9, 2017 7:10 PM in response to SGIII

I just cut that part as it is very long, but this one is a good simple example to focus on as reproduces the same issue:


-- Create a new document and save it into the Documents folder


-- generate the default file name

set todaysDate to (current date)

set the nameToUse to ¬

("Monthly Report - " & (month of todaysDate) as string) & ¬

space & (year of todaysDate) as string

--> "Monthly Report - December 2013"


-- make sure the file name is not in use

set the destinationFolderHFSPath to ¬

(path to the documents folder) as string

repeat with i from 0 to 100

if i is 0 then

set incrementText to ""

else

set incrementText to "-" & (i as string)

end if

set thisFileName to nameToUse & incrementText & ".numbers"

set thisFilePath to destinationFolderHFSPath & thisFileName

tell application "Finder"

if not (exists document file thisFilePath) then exit repeat

end tell

end repeat


tell application "Numbers"

activate

-- create a new document and store its reference in a variable

set thisDocument to make new document

-- address the document reference

tell thisDocument

-- remove any default tables

delete every table of every sheet

end tell

-- save the document

save thisDocument in file thisFilePath

end tell

Applescript and Numbers saving/exporting issue after updating to OS Sierra 10.12.2

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