Apple Numbers, cannot make new document


(Richard Brosnahan) #1

Why does this fail with an error -2710?

tell application "Numbers"
	activate
	-- create a new document and store its reference in a variable
	set theDoc to make new document with properties {document template:template "Blank"}
end tell

returns
error “Numbers got an error: Can’t make class document.” number -2710 from document to class

This is so fundamental… I’ve rebooted. I’ve tried it in SD and Script Editor. It’s like the dictionary from Numbers is hosed.

Note that doing a similar thing in Pages works just fine.

Thanks for any help, and I won’t be insulted if I’m doing something stupid.


(Mark Alldritt) #2

Sorry, I cannot be much help. When I run your script here (mac OS Sierra, Numbers 4.3.1), it works as expected.


(Richard Brosnahan) #3

I’m using macOS 10.13.2 and Numbers version 4.3.1.

I deleted Numbers.app and reinstalled it. Same error.

This is puzzling. I wonder if the Numbers.app is registered in the system incorrectly, or something… “activate” works, but not much else.

Thanks for your help!


#4

Richard,

It doesn’t look like there is an AppleScript error -2710 but there is an OS X error -2710 whose name is errOSACantCreate. This error comes from old “carbon” code and is defined in CarbonCore MacErrors.h. So whatever generated that error is probably very old code being called. You didn’t say what OS you were using. The AS line you gave works for me in Numbers 4.3.1 with no problem and I am running Sierra. It is possible “High Sierra” can’t handle it.

Since this is in fact an attempt to create something I would say this error number is probably coming straight from the OS X error in response to an AppleScript command. Version numbers might be an important factor here. What version of the OS and Numbers are you using?

The later the OS X version gets, the less trustable carbon stuff becomes.

Other than the carbon stuff I don’t have any ideas on what might be causing the problem.

Bill


(Richard Brosnahan) #5

I solved the problem, but I’m still working out just how it all fits together. I’m reluctant to post this solution as I don’t think this is a generic solution for others to use. Further, it’s almost always a bad idea to flail about in system files that you don’t understand.

  1. Deleted and installed Numbers again. No help

  2. Reinstalled macOS. No help.

  3. Checked all my prefs files with the command line tool plutil. Found a truckload of errors referencing a non-existent .plist file. One error was from Numbers.
    /Users/<home>/Library/Containers/com.apple.iWork.Numbers/Data/Library/Preferences/com.apple.security_common.plist: file does not exist or is not readable or is not a regular file (Error Domain=NSCocoaErrorDomain Code=260 "The file “com.apple.security_common.plist” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/broz/Library/Containers/com.apple.iWork.Numbers/Data/Library/Preferences/com.apple.security_common.plist, NSUnderlyingError=0x7f7f8f108690 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}})

Indeed, that com.apple.security_common.plist file does not exist. A whole bunch of the pref files are symbolically linking to that same non-existent file.
4. Checked with a friend running the same OS, and he does not have that com.apple.security_common.plist file.

  1. Noted that the file
    /Users/broz/Library/Containers/com.apple.iWork.Numbers/Data/Library/Preferences/com.apple.security_common.plist
    had a modified date of sept 2013, and that it is a symbolic link.

6.Quit Numbers

  1. Moved /Users/broz/Library/Containers/com.apple.iWork.Numbers/Data/Library/Preferences/com.apple.security_common.plist
    to~/

  2. Started Numbers

  3. Tried this again

    tell application "Numbers"
    activate
    – create a new document and store its reference in a variable
    set theDoc to make new document with properties {document template:template “Blank”}
    end tell

and it worked.

I’m not sure how this wayward pref file affected AppleScript, but it seems it certainly did. Perhaps the OS was using that old pref file to map the dictionary to the wrong app.

Thanks for your help Bill and Mark.


#6

Well I would have never thought of the apple.security_common.plist file as the problem. But apple.security plists can mess up a lot of things if they missing, corrupted or out of date. They often stop things from running altogether. Glad it worked out for you.

Bill