Michael March wrote: > When you do: > > object.Field("UserDefined_01") > > ... the output is a unicode object.. So putting: > > object.Field("UserDefined_01").Value > > .. barfs.. > > I'm obviously missing something here..
Not seeing the exact code you're using, so I could be wrong, but I would expect the result of the expression: object.Field ("blah") to be an instance of some class x.y.Field (or whatever). Since you wouldn't be able to use such a term on the LHS of a Python name-binding (object.Field("UserDefined_01") = "Open") then the first error you noted is unsurprising. I would then not be surprised if the pywin32 proxy for that field handled things like __unicode__, __str__, __repr__ in such a way as to return the ms-defined default property, typically the one called .Value which could well be a Unicode string. But obviously, if what you say above is strictly true - that object.Field ("blah").Value "barfs" (and I'm going to guess that this means: "raises an AttributeError because the builtin Unicode object has no .Value attribute) then what I'm describing above isn't happening. But am I understanding correctly? Could you provide a small code fragment which might help clarify things? Here's a toy example using Excel: <code> from win32com.client.gencache import EnsureDispatch xl = EnsureDispatch ("Excel.Application") ws = xl.Workbooks.Add ().ActiveSheet cell_11 = ws.Cells (1, 1) print cell_11.__class__ # win32com...Range cell_11 = "blah" # has now bound cell_11 to the string "blah". # It works, but isn't what we want. Rebind. cell_11 = ws.Cells (1, 1) cell_11.Value = "blah" # OK print cell_11 # "blah" because of the default property print cell_11.Value # "blah" x = cell_11 print x.__class__ # win32com...Range y = cell_11.Value print y.__class__ # type "str" </code> TJG _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32