• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Rep: No permission to save file dialog in OS X Lion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rep: No permission to save file dialog in OS X Lion


  • Subject: Rep: No permission to save file dialog in OS X Lion
  • From: pop SFR ky <email@hidden>
  • Date: Fri, 29 Jul 2011 19:18:15 +0200


Le 29/07/2011 à 12:08, Ron Hunsinger a écrit :


On Jul 28, 2011, at 5:46 PM, Brian Christmas wrote:

For a start, TextEdit no longer allied files to be save under the .txt name extension.

Well, actually it will.

You cannot save a rich-text document with a .txt name extension. To get a .txt extension, you have to save it as plain text.

If you specify a format, TextEdit insists that you also supply a destination filename. It's dictionary, however, lies. It says the destination must be an alias. That can't be right; you can only have an alias to an existing item, and you probably want to save to a new file.

Oddly enough, what it really wants is a POSIX path. (The clue is that "path of document 1" returns a POSIX path.)

set itsFldr to (path to documents folder as text) & "Unimportant_:"
set itsName to "TEDoc4.txt"
tell application "TextEdit"
save document 1 as "public.plain-text" in POSIX path of (itsFldr & itsName)
end tell

This is really a "save a copy…" operation. If the document was unsaved in TextEdit, it still is. If it has been saved, it's still based on that file.

I couldn't find a way (short of UI scripting) to convert the front document to Plain Text. Even with UI scripting, I couldn't find a way to find out the document's current format, so there's no way to know if you have to simulate a command-shift-T to switch formats or not. If the document has already been saved, you could look at it's path and get the extension from that, but if it hasn't been saved the path is still "missing value".

In fact, it's easy to achieve the described goal.


--[SCRIPT]
--=====

on switch_to_text()
tell application "TextEdit" to activate
tell application "System Events" to tell process "TextEdit" to tell menu bar 1
tell menu bar item 5 to tell menu 1
set maybe to (enabled of last menu item is true)
if maybe then click menu item 4
end tell
if maybe then keystroke return
end tell
end switch_to_text

--=====

on switch_to_rtf()
tell application "TextEdit" to activate
tell application "System Events" to tell process "TextEdit" to tell menu bar 1
tell menu bar item 5 to tell menu 1
set maybe to (enabled of last menu item is false)
if maybe then click menu item 4
end tell
end tell
end switch_to_rtf

--=====

my switch_to_rtf()

my switch_to_text()

--[/SCRIPT]

Like Shane, I'm not sure that it's really useful to work with TextEdit when datas are raw text but I'm not here to decide for the OP.

Yvan KOENIG (VALLAURIS, France) vendredi 29 juillet 2011 15:27:11








 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: SVN
  • Next by Date: Re: Applescript and Lion
  • Previous by thread: SVN
  • Next by thread: unsubscribe
  • Index(es):
    • Date
    • Thread