Re: Excel 2004 to clipboard to Finder
Re: Excel 2004 to clipboard to Finder
- Subject: Re: Excel 2004 to clipboard to Finder
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 01 Aug 2005 14:37:38 -0700
- Thread-topic: Excel 2004 to clipboard to Finder
On 8/1/05 1:15 PM, "Philip Regan" <email@hidden> wrote:
> Stupid, stupid G-Mail editor was giving me all sorts of formatting
> problems, thus the final "t". Anyway...
>
> "set dataText to Clipboard as text" is the line of code copied and
> pasted directly from the original script, so that's curious about
> adding the article.
You're right. I just checked - Excel X does have a Clipboard property of the
application, Excel 2004 doesn't. Since it does still have various special
copy and paste commands for special Excel-only circumstances (and note that
'copy range' which you used then requires a range - NOT just the text
address of the range - and is used only for copying into other ranges on a
worksheet, not to the clipboard as such) , it might mean that you can now
use the standard 'the clipboard' instead.
I just tried it.
tell application "Microsoft Excel"
set the clipboard to cell "A1"
end tell
the clipboard
--> cell "A1"
But you can't do anything with it in (most) other applications, since they
don't know what an Excel cell is. Paste into TextEdit and you get nothing
tell application "Microsoft Excel"
set the clipboard to cell "A1" as text
end tell
--> ERROR: can't make cell "A1" of app "Microsoft Excel" into a string
And that's right: you can't coerce a cell into text. This is more honest
that Excel X. But:
tell application "Microsoft Excel"
set the clipboard to (get value of cell "A1")
end tell
the clipboard
--> "abcd"
And you can paste that into TextEdit.
You can do the same thing with a larger range if you use text item
delimiters:
tell application "Microsoft Excel"
set AppleScript's text item delimiters to {return}
set the clipboard to (get value of range "A1:A3" as string)
set AppleScript's text item delimiters to {""}
end tell
the clipboard
-->
"abcd
efg
hijk"
That pastes into TextEdit too.
> But, you gave me all sorts of Applescript-goodness
> that I had thought of but couldn't quite get my head around. I'll give
> these ideas a go and shout again if I have any problems.
I'd still just get and use the data without the clipboard, by preference.
--
Paul Berkowitz
_______________________________________________
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