On Tue, Sep 13, 2011 at 10:30 AM, Colin Holgate <co...@verizon.net> wrote:

I'm trying to copy some cells from Excel (Mac, 2008 Office version) and paste it into a field in LiveCode. If I do that with Numbers all is good.
From Excel I get nothing.

'the clipboard' tells me that it contains 'text, but that 'the
clipboarddata' is apparently empty.

If I take a moment to paste the clipboard into another program, I can then
go on to paste in LiveCode ok.

Is there a way for LiveCode to see the text from Excel without first
pasting it into another program?

I think the answer is yes, depending on the design of your spreadsheet.
It is always an adventure in data format conversion when using the clipboard between apps.

When I have done this using Applescript and other programs (LC, etc.) exchanging with Excel...

I write the spreadsheet formulas to 'gather' all the values into one cell using a series of formulas, then copy that single cell.

As a better practice, I name the cell, and access it by name rather than cell address.
Using the formulated value allows you to choose your delimiters
(such as char 160 = CR, and char 161 = tab )
and avoid the variations with tab, return cross platform.
This means the same Excel formula and the same LC handler will work on all versions of Win, Mac, and incarnations of Excel.

I have used this approach for very large text runs, in particular, merging (html + values) to create complete web pages in a single cell.

Also, when switching between apps using the clipboard, be aware that you should do an Applescript line such as

tell app "Microsoft Excel"
  -- copy named cell
end tell
delay 1   -- wait 1 second
tell app "Livecode" to activate  --
delay 0.5
put the clipboarddata into tTextBlock
--now parse delims ( 161, 160 )
--etc

This gives each app time to convert the clipboard, especially if it is very large.




Jim Ault
Las Vegas



_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to