newbie needs help

Will someone please tell me why the following code works sometimes but not others?

tell application “textedit” to open “users/username/desktop/filename”

about half the time textedit says it cannot open the file

thank you all

As far as I can tell TextEdit only responds to colon-delimited paths. You could use…

tell application "TextEdit"
	open (file "Macintosh HD:Users:jobu:Desktop:file.txt")
end tell

…OR…

set myFile to "/Users/jobu/Desktop/file.txt"
tell application "TextEdit"
	open (POSIX path of myFile)
end tell

j

thank you

I knew it was something silly like that

Tip:

write this on script editor:

choose file

click on “run”

you choose you file and script editor will display on the result field the file path as it should be used on your script, just copy it and paste it on your script.