Re: TextEdit script (Applescript-users Digest, Vol 2, Issue 470)
Re: TextEdit script (Applescript-users Digest, Vol 2, Issue 470)
- Subject: Re: TextEdit script (Applescript-users Digest, Vol 2, Issue 470)
- From: "Jonathan Levi, M.D." <email@hidden>
- Date: Mon, 18 Jul 2005 21:05:19 -0400
On 18 Jul 2005 05:08:40 -0700, "B2 Fass-Holmes" <email@hidden> wrote:
Could someone please explain to me what is
defective in the following AppleScript and what
needs to be changed so that it functions
properly when I select text in TextEdit and
execute the script? It currently yields an error
NSCannotCreateScriptCommandError (even though
the script compiles successfully).
tell application "TextEdit"
activate
set font of selection to "Lucida Grande"
set size of selection to 11
end tell
Here's a partially-tested idea that uses
GUI-scripting to achieve the same object (I
assume your TextEdit document is rtf, so that the
selection can be formatted):
1. Copy the selected text to the clipboard (if
necessary, use System Events for this. Same
applies to all subsequent steps, although
probably it mostly won't be necessary.)
2. Launch AppleWorks 6 and make it create a new text document.
3. Paste the selection into the new Appleworks window.
4. Here's the critical part, which I have tested (once):
tell application "System Events" to ¬
tell process "AppleWorks 6" to tell menu bar 1
click menu item "Select All" of menu "Edit"
click menu item "Lucida Grande" of menu "Font" of ¬
menu item "Font" of menu "Text"
click menu item "12 Point" of menu "Size" of ¬
menu item "Size" of menu "Text"--there's no menu item for 11 pt
click menu item "Smaller" of menu "Size" of ¬
menu item "Size" of menu "Text"
click menu item "Copy" of menu "Edit"
end tell
5. Re-activate TextEdit and paste.
6. Dispose of untitled AppleWorks window.
HTH,
Jonathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden