Opening Templates in Pages Using AppleScript

Hi all,

I'm looking for some help opening specific Pages templates.

I have about half a dozen different templates in Pages I open regularly. I would like to have a conflict pallet with them all on so I can open them quickly.

Thought the quickest way to open them would be using AppleScript, but I don't have any experience in writing AppleScript.

Can anyone either point me in the right direction for a script that already exists, or otherwise assist?

Thanks

Hi @DIYerUK This is a a really good idea. The Template Chooser in Pages is quite clunky and slow to use. I did a Google Search and found the AppleScript to make a new document with a chosen template. (You replace my-template-name with the exact name of your template.)

Just tried this myself in a Keyboard Maestro Macro and it works fine. So, I'm going to copy your idea and make a Palette of my most used Pages Templates :grinning:

EXAMPLE New Pages Document from Template.kmmacros (45.6 KB)

tell application "Pages"
    activate

    set thisDocument to ¬
        make new document with properties {document template:template "my-template-name"}
end tell
2 Likes

Thanks for the response.

I'm so pleased you think it is a good idea.

Would you mind sharing your script? I tried copying the above into the Execute AppleScript box, but it didn't work (I must be doing something wrong, as when I type it is normal text as opposed to the coloured text above).

Thanks

I have edited my first post with a Macro that includes the AppleScript Action. You can also get the script by copying and pasting from the script block in the post.

You're a superstar. Thanks so much.

If you don't mind me ask, just for my own learning, how do I get the text to look like this AppleScript with colours, rather than just normal text? I suspect I'm doing something wrong.

Thanks

If you mean in the Keyboard Maestro Action itself?

It will change when you click the "Enter" key ⌅ (not the "Return Key"). And I have found it will also change to colours if you click on another Macro in the Editor and back again.

It will not change to colours if there is something wrong in AppleScript you have typed in.

Rather than a conflict palette with this macro repeated for each template, what about a Prompt with List action that sends the template name to theExecute AppleScript action?

1 Like