passing optional argument to win32 ole subsystem

M

Manish Sapariya

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 method.
However I am not sure how do I pass the optional argument in ruby which OLE
will understand. Following is the snippet of the sample from VBA refernce.

==============
|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
successful.
Any relevant pointers will be appreciated.

Thanks and Regards,
Manish
 
J

Jan Svitok

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 method.
However I am not sure how do I pass the optional argument in ruby which OLE
will understand. Following is the snippet of the sample from VBA refernce.

==============
|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
successful.
Any relevant pointers will be appreciated.

Thanks and Regards,
Manish

http://ruby-doc.org/docs/ProgrammingRuby/html/win32.html#UB

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.

Song.new( 'title' => 'Get It On' )

----------

So basically you just name those arguments you actually need:

myDocument.Shapes.AddOLEObject( 'Left' => 100, 'Top' => 100, 'Width' => 200,
'Height' => 300, 'FileName' => "c:\\my documents\\testing.doc", 'link' => true)
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top