Apple Event: May 7th at 7 am PT

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

AppleScript can't activate Numbers

I can't get AppleScript to activate numbers. Even the simplest script, such as:


tell application "Numbers"


activate

end tell


won't work. I get this error message:


error "An error of type -10828 has occurred." number -10828 from application "Numbers"


I'm running Mountain Lion 10.8.2 with Numbers version 2.3 on a MacBook Pro. I have the same configuration on a Mac mini and have no difficulty getting that same script to work.


Any idea how I can fix this?

MacBook Pro, OS X Mountain Lion (10.8.2)

Posted on Feb 16, 2013 3:45 PM

Reply
Question marked as Best reply

Posted on Feb 17, 2013 1:09 AM

I found a solution to my own problem: the Numbers dictionary was not part of the AppleScript Editor's library. Once I added the Numbers dictionary to the library, the activate command started working.

6 replies

Feb 17, 2013 5:41 AM in response to Mac User Since 1993

Granting that this solved the problem, I'll point out that it's not really a solution, more like a happy coincidence. -10828 is a LaunchServices error meaning that LaunchServices thinks the application needs the classic environment but can't find it. Not surprising, since classic hasn't been available since 10.4. The error speaks either to (less likely) a corruption in the Number's info.plist file or (more likely) a hiccup in the LaunchServices database. If I were you, I'd take the time to rebuild the LaunchServices database, just to be on the safe side.


run this in Terminal:


/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.fram ework/Support/lsregister -kill -r -domain local -domain system -domain user


and give it a few minutes to do its stuff. You may get a few "this application was downloaded from the internet" warnings afterwards.

Feb 17, 2013 9:02 AM in response to twtwtw

Thanks. I did the rebuild. Can't really tell whether it helped, because the Numbers issue was already solved, but I'm sure you're right about the AppleScript library solution being a happy coincidence. I couldn't find a lot of information on the web about other people getting this error, but what information I did find didn't ever involve AppleScript, so I suspected that my AppleScript problem was likely just a symptom of some larger issue.

Feb 19, 2013 8:43 AM in response to Mac User Since 1993

If it only affects Numbers it is unlikely to be a system-wide problem. A clean install may or may not fix the problem, and if it does it will only be by happenstance. But if you need some busywork... 😉


My first guesses would be the following (in no particular order):


  • You have Numbers installed on a non-local drive that gets periodically disconnected in such a way that LaunchServices forgets where Numbers is.
  • Your script is doing something funky that's causing issues with Numbers.
  • You have some sort of system cache corruption.


For the last, download a utility app like YASU or Onyx and clean out everything (a good thing to do once a year or so anyway). For the others, we'd need to know more about your script and your system setup.

Feb 19, 2013 9:41 AM in response to twtwtw

The Numbers installation is a standard, from-the-app-store install on to the MacBook's internal hard drive, and the script is literally nothing more than a tell block with one line of code, "activate." So, out of those options, I'm going to go with door number 3, system cache corruption. I'll give one of those utilities a try next.


But I may have time for some busywork later in the week...


Thanks.

AppleScript can't activate Numbers

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