How to open the TextEdit app with document open?

How to open the TextEdit app with a text document (whose extension is not .txt but .out) ?
I tried this (without success)

Var sh As New Shell
sh.Execute("open -n " + TextEdit.app)

Thanks


I changed the file extension of a text named Notes.txt to Notes.out and double-clicked into it.

Monterey told me that (above).

My answer is … use:
https://documentation.xojo.com/api/files/folderitem.html.Open

but TextEdit is not the default application to open that archaic type of file. (wikipedia)

What happens when you drag the .out file over the TextEdit app ?

Shouldn’t this be:

sh.Execute ("open -a TextEdit.app Notes.out")
3 Likes

it open it. wikipedia says it holds text data…

TextEdit can also open binary files.

Syntax error !
Another suggestion?

sh.Execute("open -a TextEdit.app Notes.out")
sh.Execute("open -a TextEdit.app")
>> Syntax error.

Double dot “.” ! Excuse me.

still not working…

dim fap As folderitem = SpecialFolder. Applications.Child("TextEdit.app") 
Shell1.Execute("open -n " + fap.ShellPath)
(try with "open -a" too)
Error message : "The file /Applications/TextEdit.app does not exist."

![Capture d'écran à Denis 2022-03-19 à 16.30.25|641x500](upload://a1GVyJK5m597U9leqc7jU5zyAYQ.png)

Hello,
What does this message mean? Why it seems impossible to launch the application!


Thanks

Is TextEdit.app in your Applications folder? It is on my machine.

Yes, there is. That is why I do not understand.

That path is to your user Application directory, you should be targeting /Applications, not ~/Applications

1 Like

The open command uses the “-e” option to open the specified file in TextEdit.

This code works for me:

RunShell = New Shell // Property RunShell As Shell

Var file As FolderItem = SpecialFolder.Desktop.Child("simple.out")

RunShell.Execute("open -e " + file.ShellPath)
2 Likes

I would highly suggest to use an API and not command line to open it.
Like using LaunchServicesOpenXMBS function in MBS Xojo Plugins.

Works for me too ! Thank you very much @Paul_Lefebvre (and @Emily-Elizabeth_Howard too)