MS Windows automation - howto use it?

N

Nuralanur

-------------------------------1110976291
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Dear Ruby experts,

I would like to use Ruby's WIN32OLE and/or WIN32API capability to
automate a translation application.
In the documentation on the web, there are examples on how to
use Ruby to create Excel and Word documents and to write to them.

My problem is now that I do not know how to tell Ruby what to substitute in
the book example's lines

ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome

so that my application is loaded ( is it always NameoftheProgram.Application
?)
and what methods are then available to that object. I need to pass text into
a field, for instance ....

Thank you for your help!

Best regards,

Axel



-------------------------------1110976291--
 
D

Dave Burt

----- Original Message -----
I would like to use Ruby's WIN32OLE and/or WIN32API capability to
automate a translation application.
In the documentation on the web, there are examples on how to
use Ruby to create Excel and Word documents and to write to them.

My problem is now that I do not know how to tell Ruby what to substitute in
the book example's lines

ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome

so that my application is loaded ( is it always NameoftheProgram.Application
?)
and what methods are then available to that object. I need to pass text into
a field, for instance ....

Martin Kahlert asked a similar question a few weeks ago, in the thread "Windows
automation":
http://rubyurl.com/pklBm [1]

Depending on what you want to do, you may find an answer there (there are about
3 suggestions in that thread, the worst of which is mine, I believe :).
Otherwise, check out Watir [2] and I'm sure there's at least one more project in
the RAA [1] that can help you with what you're trying to do.

Now, I'll try and answer your direct questions with some explanation of stuff
you don't seem to understand.
"InternetExplorer.Application" is known in Windows as a "program id". Others
might include "Excel.Application", "Word.Application", "Scripting.Regexp",
"Scripting.FileSystemObject" (but why would you use either of these latter from
Ruby?)
I am pretty sure you can substitute a program id in the WIN32OLE constructor
with a class id, which looks more like "{6BF52A52-394A-11D3-B153-00C04F79FAA6}"
(Flash object). It's just a different way to specify what OLE object to create.

How do you know what methods your new Flash object has? That's tricky - you
can't just use my_ole_object.methods, because it doesn't actually have any
special ones - it uses method_missing. You need to check the documentation for
the OLE object itself. When I'm developing using Word and Excel automation, I
usually develop that code in Word and Excel (record macros, use the help and the
object browser to help figure out how to do whatever I need to do) and then just
translate that to Ruby (it's pretty straightforward).

Cheers,
Dave

[1]
http://groups.google.com.au/groups?...t+windows+automation&hl=en&btnG=Google+Search

[2] http://wtr.rubyforge.org/
 
T

Thomas

How do you know what methods your new Flash object has? That's tricky -
you can't just use my_ole_object.methods, because it doesn't actually
have any special ones - it uses method_missing.

Minor note: You could probably use the #ole_methods method to get a
(partial) list of known methods. Doesn't give you any information on
method arguments though which is why you would probably need the
documentation anyway.

Cheers,
Thomas.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top