Expanding a 'TextExpander' snippet from within 'Textedit'

I have been unsuccesfully trying to write a piece of AppleScript code that will open a new document in Textedit and then expand a snippet I created in TextExpander. I’ve had several suggestion from ‘Apple Support Communities’ board none of which have worked. The snippets name is “Excused absence” and it is just a Rich Text formatted document that my daughter can take to the attendance office when she misses school.

Although I think it should be a simple script, it is proving to be a challenge.

I would deeply appreciate any and all help anyone can provide.

Model: MacBook Pro Retina
AppleScript: 2.7
Browser: Safari 600.5.17
Operating System: Mac OS X (10.8)

Hi denny da Monkeyguy,

What do you mean by:

Don’t know what you mean by expand.

gl,
kel

Sorry if I wasn’t clear… to expand a snippet actually means to execute the snippet (like a keyboard macro) and insert the enclosed text in another document, window etc…

Hello everyone, just to let you know, the solution to my scripting problem was in not accounting for the fact that ‘Textexpander’ is faster than ‘Textedit’ thus a delay was needed prior to the expansion… the solution code is here:

tell application “TextEdit”
make new document
activate – go to the foreground
end tell
do shell script “sleep 2” – delay of 2 seconds (increase time, if it expand in the Script window.)
tell application “TextExpander” to expand abbreviation “/excuse”

:slight_smile:

p.s. I was able to reduce it to 1 second and it still works great :smiley: