TextEdit: Save the current document as HTML

If you’ve opened a named doc it will save it by its name. If it’s a new doc, it will be named “Unitled?” with numbers where the ? is. Any formatting in an RTF or Word files is retained in the HTML. Note the two lines where you must remove hyphens if running as a workflow. (Requires UI scripting enabled.)

--Save TextEdit Doc as HTML
--tell application "TextEdit" to activate--remove hypens before "tell" if running as a workflow
tell application "System Events"
tell process "TextEdit"
keystroke "S" using command down
delay 1
click pop up button 1 of group 1 of sheet 1 of window 1 
delay 1
key code 125
delay 1
keystroke return
delay 1
keystroke return
end tell
end tell
--end tell --remove hypens before "end" if running as a workflow