Friday, January 28, 2022

#1 2022-01-14 06:26:57 pm

TheKrell
Member
Registered: 2020-03-08
Posts: 16

Text Edit in plain text

Applescript:

tell application "TextEdit"
   activate
   make new document
end tell

This works fine for then keystroking text into the open document.  But how do I make it open to so that the result is in plain text?

Thank you.

Offline

 

#2 2022-01-15 12:44:57 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2208

Re: Text Edit in plain text

This question has been answered numerous times.

TextEdit will not be able to create a plain text document when is specified "rich text" in its default mode settings. Either 1) specify "plain text" in the settings (manually), or 2) it is better - use Finder's help for your task:

Applescript:


tell application "Finder"
   set plainTextFile to make new file at desktop with properties {name:"Test.txt"}
end tell

tell application "TextEdit"
   activate
   open file (plainTextFile as text)
   set plainTextDocument to front document
end tell

Last edited by KniazidisR (2022-01-15 12:50:03 am)


Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#3 2022-01-15 01:44:42 am

TheKrell
Member
Registered: 2020-03-08
Posts: 16

Re: Text Edit in plain text

Thank you KniazidisR,
   The second suggestion works nicely.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)