Can Revolution communicate with Excel?

xbury.cs at clearstream.com xbury.cs at clearstream.com
Fri Mar 18 02:32:51 EST 2005


Thanks Ken,

That will save me a bit of research and testing I was preparing ;)

cheers
Xavier

On 18.03.2005 08:18:11 use-revolution-bounces wrote:
>That's neat. Now it means I can 'script' complex .NET code too...
>
>Thanks
>
>Vikram
>
>Ken Ray <kray at sonsothunder.com> wrote:
>On 3/17/05 7:06 PM, "Stgoldberg at aol.com" wrote:
>
>> Wow! I'm a new user and really impressed with how quick (and accurate) 
my
>> first question was answered. I thank everyone who answered. Perhaps 
someone
>> can
>> also answer the following: Is there any way in which data (e.g. a 
number)
>> calculated at in a Revolution stack can be automatically transferred to 
a
>> given
>> cell (field) in an Excel program? Thanks again.
>
>Here's the way to do it for Mac. The basic script for AppleScript is like
>this:
>
>tell application "Microsoft Excel"
>set value of cell "B3" to 500
>end tell
>
>To translate this to Revolution, you'd do this (I use a q() function for
>quoting data that makes it easier to work with):
>
>on mouseUp
>SendToXL "500","B3"
>end mouseUp
>
>on SendToXL pWhat,pCell
>put "tell app" && q("Microsoft Excel") & cr & \
>"set value of cell" && q(pCell) && "to" && q(pWhat) & cr & \
>"end tell" into tScript
>do tScript as AppleScript
>end SendToXL
>
>function q pWhat
>return quote & pWhat & quote
>end q
>
>----------
>
>Here's the way to do it for Windows. The basic VB Script code looks like
>this:
>
>Dim ObjXL
>Set ObjXL = GetObject(,"Excel.Appliction")
>ObjXL.Range("B3").Value = "500"
>
>To translate this to Revolution, you need to output this to a .vbs file 
and
>"run" it, and then delete it when you're done. Here's how:
>
>on mouseUp
>SendToXL "500","B3"
>end mouseUp
>
>on SendToXL pWhat,pCell
>put "Dim ObjXL" & cr & \
>"Set ObjXL = GetObject(," & q("Excel.Application") & ")" & \
>"ObjXL.Range(" & q(pCell) & ").Value =" && q(pWhat) into tScript
>
>-- Put the script into a file on disk
>put "C:\VBSTemp.vbs" into tFile
>put tScript into url("file:" & tFile)
>
>-- Run the file
>set the hideConsoleWindows to true
>get shell("cscript.exe //nologo" && tFile)
>
>-- Now, delete the file; best way is to give it 1 second to complete
>-- before deleting, so I'll use the "send in " method to
>-- do this:
>send "delete file" && q(tFile) to me in 1 second
>end SendToXL
>
>
>If you're developing cross-platform, you can merge them into the same
>handler by checking "the platform":
>
>on SendToXL pWhat,pCell
>switch (the platform)
>case "MacOS"
>-- put the Mac code here
>break
>case "Win32"
>-- put the Windows code here
>break
>end switch
>end SendToXL
>
>Hope this helps,
>
>Ken Ray
>Sons of Thunder Software
>Web site: http://www.sonsothunder.com/
>Email: kray at sonsothunder.com
>
>
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
>---------------------------------
>Do you Yahoo!?
>Yahoo! Small Business - Try our new resources site!
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>http://lists.runrev.com/mailman/listinfo/use-revolution


-----------------------------------------
Visit us at http://www.clearstream.com
IMPORTANT MESSAGE    Internet communications are not secure and therefore
Clearstream International does not accept legal responsibility for the
contents of this message.    The information contained in this e-mail is
confidential and may be legally privileged. It is intended solely for the
addressee. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken or omitted to be taken in reliance on it,
is prohibited and may be unlawful. Any views expressed in this e-mail are
those of the individual sender, except where the sender specifically states
them to be the views of Clearstream International or of any of its
affiliates or subsidiaries.    END OF DISCLAIMER


More information about the use-livecode mailing list