Win32ole question

I have a 3rd party COM library, and this works in VBScript:

Set foo = CreateObject(“Foo”)
foo.Fields(“FieldA”) = 5
foo.Fields(“FieldB”) = “bar”
WScript.Echo foo.Fields(“FieldA”)
WScript.Echo foo.Fields(“FieldB”)

but I can’t get the assignments to work in ruby:

foo = WIN32OLE.new(“Foo”)
foo.Fields(“FieldA”) = 5

it errors out on this, because the evaluation up until the assignment of
results in a Fixnum instance that has no “=” method or somesuch. I
suspect
there’s a way to workaround this with something like the _setproperty
method
but I couldn’t wrap my brain around it today. Anyone have a hint? Or is
this
a weird edge case in the land of COM that win32ole can’t work with?

Chris,

To set properties with win32ole, use the property syntax, rather than
accessing the property via method:

foo[“FieldA”] = 5

Mitchell H.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs