Forum: Ruby passing optional argument to win32 ole subsystem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
35087ac552d8c3d182d3eaf4659517d9?d=identicon&s=25 Manish Sapariya (Guest)
on 2007-02-22 03:31
(Received via mailing list)
Hi all,
I am trying to embed a html document in Excel document using Win32OLE.
The VBA Excel reference talks about this by using the OleObject Add
However I am not sure how do I pass the optional argument in ruby which
will understand. Following is the snippet of the sample from VBA

|Set myDocument = Worksheets(1)
myDocument.Shapes.*AddOLEObject* Left:=100, Top:=100, _ Width:=200,
Height:=300, _ FileName:="c:\my documents\testing.doc", link:=True|

I tried passing null, but it failed miserably. I am not sure if I pass
some argument incorrectly
or the method I am using to pass the arguments is incorrect.
Can somebody let me know the exact syntax in ruby to make this call
Any relevant pointers will be appreciated.

Thanks and Regards,
97550977337c9f0a0e1a9553e55bfaa0?d=identicon&s=25 Jan Svitok (Guest)
on 2007-02-22 11:43
(Received via mailing list)
On 2/22/07, Manish Sapariya <> wrote:
> ==============
> Manish

Named Arguments

Other automation client languages such as Visual Basic have the
concept of named arguments. Suppose you had a Visual Basic routine
with the signature:

Song(artist, title, length):    rem Visual Basic

Instead of calling it with all three arguments in the order specified,
you could use named arguments.

Song title := 'Get It On':      rem Visual Basic

This is equivalent to the call Song(nil, 'Get It On', nil).

In Ruby, you can use this feature by passing a hash with the named
arguments. 'title' => 'Get It On' )


So basically you just name those arguments you actually need:

myDocument.Shapes.AddOLEObject( 'Left' => 100, 'Top' => 100, 'Width' =>
'Height' => 300, 'FileName' => "c:\\my documents\\testing.doc", 'link'
=> true)
This topic is locked and can not be replied to.