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: Yvan KOENIG <email@hidden>
- Date: Tue, 19 Jul 2005 18:27:19 +0200
Le 19 juil. 2005 , à 3:05, Jonathan Levi, M.D. a écrit :
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.
Hello
It would be easier to do steps 2 to 6 in this single script.
tell application "AppleWorks 6"
activate
select menu item 1 of menu item 1 of menu 2 -- new text document
select document 1
tell document 1
select menu item 5 of menu 3 -- Paste
select menu item 7 of menu 3 -- select all
select menu item "Lucida Grande" of menu item 1 of menu 5 -- set font
tell selection
set size to 11
end tell -- selection
select menu item 3 of menu 3 -- Cut
end tell -- document 1
close document 1 saving no
end tell -- AppleWorks
CAUTION
If the original text contains too many attributes changes, it will be
impopssible to paste it into AppleWorks.
Yvan KOENIG (from FRANCE 19 juillet 2005 18:26:48)
PS: I was ready to post when I saw your new script.
_______________________________________________
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