[Wtr-general] Can I attach to an open Excel session?

Ethan Jewett esjewett at gmail.com
Sun Dec 10 09:35:31 EST 2006


Lou,

Here, Google is your friend.  "ruby excel" yields:
http://wiki.rubygarden.org/Ruby/page/show/ScriptingExcel

Check out the section called "Some further stuff that I learned so
far".  It illustrates the method used to do exactly what you want to
do, which is attach to a running excel session.

For future reference, the win32ole section of the documentation for
the ruby standard library is located here:
http://www.ruby-doc.org/stdlib/libdoc/win32ole/rdoc/index.html

Ethan

On 12/10/06, Lou Wilson <forum-watir-users at openqa.org> wrote:
> Good point about the open excel file being seen as locked.
> However, look at other testing languages, how they can punch in on the UI of a running program and access the objects on that application.  Excel is no different a target in that way.  If I write a c# or vb program that uses Win32API calls, and if I know the hWnd handle of the target application, I can send commands to the objects in that application, even if it's already open.  I suspect some people are already doing that with Ruby.  So I might have answered my own question here.  I will start another thread asking about Win32API in Ruby.
>
> And as far as creating code in Excel with VBA from within the spreadsheet, try it.  You might like it.  The code my macros create does not do the main work of the ruby/watir code: I have functions written in Ruby files already, and called as includes.  The VBA script writes out the header and variables to a ruby file, then fires up the file.  There are controls on the face of the spreadsheet that let the user choose whether to fire up ruby directly, or execute it in SCITE for debugging purposes.
>
> As far as having trouble is concerned, consider this:  I started on this job last year.  The previous tester that was manually testing this one process, took a whole day to do the test case.  My process with Excel / Ruby / Watir executes 430 instances of the process in an overnight run.  And I can let a non-programmer tester do the setup and fire off the test while I'm gone.
>
> We are also running Silk in the house, and my Excel/Ruby hybrid outperforms the Silk Test version of one of the same tests seven ways from sunday, especially in speed of execution, maintainability of the code, and ability to have non-programmers use the Excel interface.
>
> Incidentally, I am using varients of the same VBA code to generate some of the Silk Test scripts for the Silk programmers where I work.  For tests that have already been developed in Silk, but use some of the data I store on the Excel sheets for my test area, I have an option on the sheets that allows the target script to be written in Silk instead of Ruby.
>
> So your opinion about using Excel to write and launch Ruby code is falling on deaf ears here.
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.openqa.org/thread.jspa?threadID=5687&messageID=15929#15929
> _______________________________________________
> Wtr-general mailing list
> Wtr-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
>


More information about the Wtr-general mailing list