pywin32 - word object reference module - automating form filling

Brendan brendandetracey at
Tue Jun 9 08:54:15 EDT 2009

I was hoping to use pywin32 to automate some rather tedious filling in
of Word forms. I thought the process would be analogous to dealing
with xml documents or DOM but find myself somewhat lost in the word
object reference manual (
bb244515.aspx) .  I was hoping to easily load all document objects
into a list so that I could poke around, examine and experiment with
them. So far all I have managed to do is load the page content as a
string, not particularly helpful.

Could someone please point me in the right direction?

Also, help, __doc__ and dir do not return anything meaningful(to me
anyway) or helpful. There seem to be no exposed methods or properties.
e.g. I have a word document object:
wd = wordapp.Documents.Open('blah.dic')
>>> dir(wd)
['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum',
'_Release_', '__AttrToID__', '__LazyMap__', '__call__', '__cmp__',
'__doc__', '__getattr__', '__getitem__', '__init__', '__int__',
'__len__', '__module__', '__nonzero__', '__repr__', '__setattr__',
'__setitem__', '__str__', '_builtMethods_', '_enum_',
'_find_dispatch_type_', '_get_good_object_',
'_get_good_single_object_', '_lazydata_', '_make_method_',
'_mapCachedItems_', '_oleobj_', '_olerepr_', '_print_details_',
'_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_']

>>> print wd.__doc__

    The dynamic class used as a last resort.
    The purpose of this overriding of dynamic.CDispatch is to
perpetuate the policy
    of using the makepy generated wrapper Python class instead of
    if/when possible.

>>> help(wd)
Help on instance of CDispatch in module win32com.client object:

class instance(object)
 |  instance(class[, dict])
 |  Create an instance without calling its __init__() method.
 |  The class must be a classic class.
 |  If present, dict must be a dictionary or None.
 |  Methods defined here:
 |  __abs__(...)
 |      x.__abs__() <==> abs(x)

~ ~ snip ~ ~

|  __truediv__(...)
 |      x.__truediv__(y) <==> x/y
 |  __xor__(...)
 |      x.__xor__(y) <==> x^y
 |  next(...)
 | -> the next value, or raise StopIteration
 |  Data and other attributes defined here:
 |  __new__ = <built-in method __new__ of type object at 0x1E1C74D0>
 |      T.__new__(S, ...) -> a new object with type S, a subtype of T

What gives?

More information about the Python-list mailing list