# Win32ole question

**URL:** <https://www.ruby-forum.com/t/win32ole-question/186502>\
**Category:** Ruby\
**Created:** [April 8, 2010, 2:35am UTC](https://www.ruby-forum.com/t/win32ole-question/186502 "2010-04-08T02:35:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [April 8, 2010, 2:35am UTC](https://www.ruby-forum.com/t/win32ole-question/186502/1 "2010-04-08T02:35:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [April 8, 2010, 2:59am UTC](https://www.ruby-forum.com/t/win32ole-question/186502/2 "2010-04-08T02:59:58Z")

</div>

Chris,

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

foo[“FieldA”] = 5

Mitchell H.
