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

Question:

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

Reply

There’s more to the conversation

Read all replies

Jan 9, 2017 6:59 PM in response to International Traveler In response to International Traveler

When you post a script it's usually better to post the whole thing to make it easier for others to test.


For ways to save documents you might want to have a look at the scripts on this page. Do they work on your machine?


SG

Jan 9, 2017 6:59 PM

Reply Helpful

Jan 9, 2017 7:02 PM in response to SGIII In response to SGIII

Hi SGIII, yes, tried that one already and same thing happened:


The document “Untitled” could not be saved as “Monthly Report - January 2017.numbers”. You don’t have permission.

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

Jan 9, 2017 7:02 PM

Reply Helpful

Jan 9, 2017 7:10 PM in response to SGIII 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

Jan 9, 2017 7:10 PM

Reply Helpful

Feb 2, 2017 3:04 PM in response to International Traveler 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

Feb 2, 2017 3:04 PM

Reply Helpful
Question marked as Solved

Feb 2, 2017 3:06 PM in response to International Traveler 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

Feb 2, 2017 3:06 PM

Reply Helpful
User profile for user: International Traveler

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