[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Win32OLE. Opening an existing file.

Peter Bailey

10/26/2006 12:44:00 PM

Hi,
Can someone tell me how I can use Win32OLE to open an existing file? All
the doc I've seen just shows you how to start a new file, like this:

require 'Win32ole'
excel = WIN32OLE.new("excel.application")

Thanks,
Peter


--
Posted via http://www.ruby-....

4 Answers

Victor 'Zverok' Shepelev

10/26/2006 12:48:00 PM

0

Peter Bailey (pbailey@bna.com)
26/10/2006 15:44:12

> Hi,
> Can someone tell me how I can use Win32OLE to open an existing file? All
> the doc I've seen just shows you how to start a new file, like this:
>
> require 'Win32ole'
> excel = WIN32OLE.new("excel.application")

excel = WIN32OLE.new('excel.application')
book = excel.Workbooks.Open(path)

Typical answer for all similar questions: open Excel, start macro recording, do what you want, stop macro recording. Open recorded macro - it would be in VBA, but can be ported into Ruby w. WIN32OLE pretty straightforward.

V.


Peter Bailey

10/26/2006 1:13:00 PM

0

Victor 'Zverok' Shepelev wrote:
> Peter Bailey (pbailey@bna.com)
> 26/10/2006 15:44:12
>
>> Hi,
>> Can someone tell me how I can use Win32OLE to open an existing file? All
>> the doc I've seen just shows you how to start a new file, like this:
>>
>> require 'Win32ole'
>> excel = WIN32OLE.new("excel.application")
>
> excel = WIN32OLE.new('excel.application')
> book = excel.Workbooks.Open(path)
>
> Typical answer for all similar questions: open Excel, start macro
> recording, do what you want, stop macro recording. Open recorded macro -
> it would be in VBA, but can be ported into Ruby w. WIN32OLE pretty
> straightforward.
>
> V.

Thanks, Victor. I tried it with an existing file, and, it worked! It's
pretty slow, but, the books warned me about that. So, are you saying
that all of the WIN32OLE instructions are simply VBA instructions? So,
technically, I could derive my answers by just looking at the VBA help
in Word or Excel??

--
Posted via http://www.ruby-....

Ken Bloom

10/26/2006 1:48:00 PM

0

On Thu, 26 Oct 2006 22:12:51 +0900, Peter Bailey wrote:

> Victor 'Zverok' Shepelev wrote:
>> Peter Bailey (pbailey@bna.com)
>> 26/10/2006 15:44:12
>>
>>> Hi,
>>> Can someone tell me how I can use Win32OLE to open an existing file? All
>>> the doc I've seen just shows you how to start a new file, like this:
>>>
>>> require 'Win32ole'
>>> excel = WIN32OLE.new("excel.application")
>>
>> excel = WIN32OLE.new('excel.application')
>> book = excel.Workbooks.Open(path)
>>
>> Typical answer for all similar questions: open Excel, start macro
>> recording, do what you want, stop macro recording. Open recorded macro -
>> it would be in VBA, but can be ported into Ruby w. WIN32OLE pretty
>> straightforward.
>>
>> V.
>
> Thanks, Victor. I tried it with an existing file, and, it worked! It's
> pretty slow, but, the books warned me about that. So, are you saying
> that all of the WIN32OLE instructions are simply VBA instructions? So,
> technically, I could derive my answers by just looking at the VBA help
> in Word or Excel??
>

Precisely. VBA is just another language for controllng OLE objects, so the
same API's are available for VBA and Ruby (and any other language you
might choose that talks OLE).

--Ken

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...

Peter Bailey

10/27/2006 12:19:00 PM

0

Ken Bloom wrote:
> On Thu, 26 Oct 2006 22:12:51 +0900, Peter Bailey wrote:
>
>>>
>> Thanks, Victor. I tried it with an existing file, and, it worked! It's
>> pretty slow, but, the books warned me about that. So, are you saying
>> that all of the WIN32OLE instructions are simply VBA instructions? So,
>> technically, I could derive my answers by just looking at the VBA help
>> in Word or Excel??
>>
>
> Precisely. VBA is just another language for controllng OLE objects, so
> the
> same API's are available for VBA and Ruby (and any other language you
> might choose that talks OLE).
>
> --Ken

Interesting. I noticed that, in the Win part of these instructions, the
path was only respected when done with "\" instead of the Rubyish "/."
So, it really is one world within another. Thanks!

--
Posted via http://www.ruby-....