AppleScript & Numbers error - The file format is invalid.

Here is a simple AppleScript to open a file:


set FileName to choose file of type "numbers" with prompt "Open File"

tell application "Numbers"

set DocName to open FileName

activate

end tell


It works.


But I don't need the interaction, I'd prefer to just set FileName to a fixed string, like this:


set FileName to "Source.numbers"

tell application "Numbers"

set DocName to open FileName

activate

end tell


But at runtime I get this error:


Seems I need to apply (of type "numbers") to FileName somehow but I can't figure it out.


Any ideas?

MacBook Pro (2017 – 2020)

Posted on Apr 11, 2024 3:46 PM

Reply
Question marked as Top-ranking reply

Posted on Apr 11, 2024 3:50 PM

Use:


set FileName to alias "Source.numbers"


or:


tell application "Numbers"

set DocName to open alias "Source.numbers"

activate

end tell


(252342)

Similar questions

4 replies

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 & Numbers error - The file format is invalid.

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