Hello.
I need some help with a very simple script (so I think).
I made an application with Automator that brings up a textedit file that can be filled out by the user.
After 30 secs a dialog pops up that allows the user to “send” or discard this file after finishing the input. The sending is then done by a shell script (which a friend wrote for me). It all works smooth…
However, I would like the textedit file to be opened as a copy of the original, so that always the same layout and questions pops up and can not be changed by a “funny” user (the app and mac is accessible in public).
This I easily achieved by just ticking “formblock {?}” (Formularblock in the german OS X) in the info for the file. So when I open the file in the finder by doubleclicking a copy is made and opened.
But when I open the file with an applescript embedded in the Automator app, it only opens the original…
Obviously the very simple script I used looks as follows:
on run {input, parameters}
tell application "TextEdit"
activate
open "Users:johannes:documents:dialog.rtf"
end tell
return input
end run
ANY IDEAS how I can get around this seemingly very easy problem? e.g. telling textedit in the script to open the file as a copy…
Many thx
Hi,
if the Finder opens the file as a template, so let the Finder open the file
set dialogFile to ((path to documents folder as text) & "dialog.rtf")
tell application "Finder" to open alias dialogFile using application file id "com.apple.textedit"
Hi Stephan,
thanks a lot for the quick reply.
Unfortunately it doesn’t work for me.
Automator tells me: Finder reports error žalias “Users:johannes:documents:merhaba2.rtf”" can not be read.
By writing Finder can open it, I basically just meant I can doubleclick the file and it opens as a copy of the original.
Any other suggestions?
Grüezi
I tested it in Script Editor and it worked fine.
Is the file path valid?
Edit:
this worked in Automator, too
on run {input, parameters}
set dialogFile to ((path to documents folder as text) & "dialog.rtf")
tell application "Finder" to open alias dialogFile using application file id "com.apple.textedit"
return input
end run
Hi Stephan,
well, path is valid indeed, still I get:
žFinder" hat einen Fehler erhalten: žalias “Users:johannes:documents:test.rtf”" kann nicht gelesen werden.
Different file (test.rtf) same happened…
Can it maybe be that I need to install some additional applescript tools to my standard OS so it can work?
I am very new to all this programming stuff, so please excuse my clumsiness.
thx
No, a HFS path starting with Users is no valid path. It must start with a disk name.
Please use the relative path (path to documents folder as text) which points to the current user’s
documents folder
Well well - an absolute beginner using apple script.
But now it works very well!
Thank you, Stephan!