Reputation: 13
So I'm new to applescript and I'm trying to create an app that will open microsoft word and then save the document every once in a while automatically and then stop running once I close Word. This is my code so far:
activate application "Microsoft Word"
if application "Microsoft Word" is running then
repeat
delay 5
tell application "Microsoft Word" to save front document
end repeat
end if
It works up until the point that I quit word. Even though I have it set to end if word isn't running it still tries to save to word and then I get an error message. Another interesting thing to note is that it even says end tell in the script once I quit word.
What am I doing wrong?
Upvotes: 1
Views: 165
Reputation: 11238
Save this as a stay-open application:
activate application "Microsoft Word"
on idle
say "idle"
if application "Microsoft Word" is running then tell application "Microsoft Word" to save front document
return 5 -- in seconds
end idle
Upvotes: 2