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 12:45:49 -0700
- Thread-topic: Excel 2004 to clipboard to Finder
On 8/1/05 11:37 AM, "Philip Regan" <email@hidden> wrote:
> Howdy--
>
> I've upgraded from Excel v.X to 2004 on 10.3.9 and I'm hvaing a
> problem porting a s a script to the new version. The part that is the
> problem is that I copy columns of text from Excel to the clipboard for
> sorting and parsing. The original code looked like this:
>
> tell application "Microsoft Excel"
> [activate, open worksheet]
> repeat with c from 1 to (get the count of columnsLettersAll)
> CopyObject column (item c of columnsLettersAll)
> set dataText to clipboard as text
> [process text in subroutines]
> end repeat
> end tell
>
> According to the 2004 dictionary and the Excel2004AppleScriptRef.pdf,
> this should work:
>
> tell application "Microsoft Excel"
> [activate, open worksheet]
> repeat with c from 1 to (get the count of columnsLettersAll)
> set currentColumn to (item c of columnsLettersAll)
> set theRange to currentColumn & "2" & ":" & currentColumn &
> ((imageCount + 1) as string)
> set dataRange to range theRange of sheet 1
> copy range dataRange
>
> set dataText to clipboardt
> [process text in subroutines]
> end repeat
> end tell
>
> What's happening is the data is being copied to the clipboard, but
> won't go to the dataText variable. I just get "missing text" in the
> Event Log. I've tried adding a Tell to the Finder, and similar
> variations, but to no avail/ . Anyone have an ideas?
First of all
set dataText to clipboardt
isn't going to do anything, even if you spell it correctly. It has to be
'the clipboard' - it must have 'the '. that's the command in Standard
Additions - 'the clipboard'. That was true even when you used Excel X - you
just must have included 'the' back then.
Then, this bit shouldn't really be in the Excel tell block. So just in case
you did actually include 'the ' and it's still not working, try it outside
the tell block. It's also quite possible that the Excel 2004 clipboard to
which you copy using Excel's 'copy' command may not be the system clipboard
you access using 'the clipboard' command. (I haven't tested, but this is
quite possible. 'Excel's 'copy' may copy to Office 2004's own "Scrapbook",
not to the system clipboard. You could try using 'set the clipboard to'
instead. But I don't know where the coercion to text is taking place -
whether Excel is doing that, or what. There might still be problems if the
coercion doesn't work with the Stand 'set the clipboard to', which I suspect
it may not.
Personally, I would not use the clipboard. I would get the value of each
column - which will be a list of lists. Outside the Excel block I would then
use AppleScript's text item delimiters (set to return, or tab, or whatever
is most useful) to coerce the list of lists to text if you need it as text
rather than as a list.
--
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