macosapplescriptkeynoteiwork

Opening a Keynote Presentation using AppleScript (Keynote 6.5.2)


I am trying to see if i can change the text of some slides inside a keynote presentation that has already been created but i am having problems just opening it to begin with.

here is my current simple applescript:

set thisFile to "Users/myUserName/Desktop/KeynoteAppleScript.key"

    tell application "Keynote"

        activate

        open thisFile

        show slide 1

  end tell

I get an error stating that the file I am trying to open :

"Users/myUserName/Desktop/KeynoteAppleScript.key" couldnt be opened because there is no such file".

Thats obviously not correct, it is there and the i have double checked the name of the file to verify.

I am using Keynote 6.5.2

Script Editor Version 2.7, AppleScript 2.4

What am I doing wrong here?


Solution

  • Try adding a leading fwd slash to the path

    e.g,

    set thisFile to "/Users/myUserName/Desktop/KeynoteAppleScript.key"
    

    I needed to do this to get it opening on 10.8, Keynote 5.3

    ALSO..

    When in doubt with a file path, try dragging the file from the desktop to the script window and it will insert a correct path.