Type keystroke

I’m creating a macro 
to automatically open a word 2011 personal template.

I get an error when i try to choose the template.

The the actions sequence is the following:

type the shift+command+P Keystroke to create a
new document from a template: ok

type the tab keystroke two times to activate the
template choice: ok

type the up arrow keystroke to reach the
personal template section: ok

type the tab keystroke to enter the right side
of the personal tempalte section where are my templates: ok

at this point i should add the action “type
the right arrow keystroke” to reach the second personal template but the action
does not work and i get a beep error (as if I had pressed a key not enabled in
that section of Word)

Can you give me some advice ?

Hey Enrico,

You’re doing that the hard way. Try this AppleScript, and rename the template in the 3rd line.

tell application "Microsoft Word"
  set userTemplatesFldr to get default file path file path type user templates path
  set myTemplate to userTemplatesFldr & ":Normal.dotm"
  open myTemplate
end tell


thank you, it works fine

Hi Chris,
i recently upgraded to Mavericks my computer and since i have done this the script doesn’t work: have you any idea how to fix the problem? the template is not found and remains the initial blank sheet.

Hey Enrico,

The question is did you change anything? I wrote the script on Mavericks, so that’s not the issue.

Try the script below. I’ve improved it slightly.

Keep in mind that the path used in the script is HFS rather than Posix, so it uses “:” as a separator instead of “/”.

Expanded out it looks like this, except it will show your hard drive, user, and template name.

"Ryoko:Users:chris:Library:Application Support:Microsoft:Office:User Templates:Normal.dotm"

If you moved the template to a folder you have to account for that. Rename Normal.dotm as needed.

set templateName to "Normal.dotm"
tell application "Microsoft Word"
  set userTemplatesFldr to get default file path file path type user templates path
  set myTemplate to userTemplatesFldr & ":" & templateName
  open file myTemplate
end tell

If you’re still having problems get the path of your template on disk, and compare it to the value of the myTemplate variable.

This is a super simple script, so it should just work.


Hi Chris,

Attached you find the path to reach the template i need (named
³preventivo.dotx²): how i have to fix the script?

thank you

Enrico Angelini

Hey Enrico,

In the newest script you should be able to simply change the name of this variable to:

set templateName to “preventivo.dotx”`


I get this error message:

821F3-B42B-4EDE-A3BA-CBAD3A8F4A1F:122:126: script error: Expected end of
line, etc. but found class name. (-2741)

Enrico Angelini

Hey Enrico,

Always trial run AppleScript from the AppleScript Editor. Don’t move it to Keyboard Maestro until it’s working.

Please contact me off-list, and we’ll see if we can get to the bottom of this.


  • I’ll be off-the-air for about 12 hours or so.


You can sometimes get errors when executing scripts in Keyboard Maestro if you have one or more variables that are very large or contain binary characters (eg you read an image file or pdf into a variable). The reason for this is that Keyboard Maestro places your variables into environment variables before executing script (including AppleScripts), and it is possible for large or binary values in the environment to cause the system to choke.

So check your variables (Keyboard Maestro ➤ Preferences, Variables pane) and see if any are large or weird.

Hi Chris,

today i have updated mac osx to 10.9.5 and the the script doesn¹t work
anymore (the same erro).

Can you fix it ? can also explain me what¹s the matter?


Enrico Angelini