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
10 replies

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

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.

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.