win32com and makepy

Mark Hammond MarkH at ActiveState.com
Fri Feb 23 20:44:27 EST 2001


Sean Laurent wrote:

> Howdy  All,
> I'm having a strange problem with win32com.client.Dispatch().  I used
> win32com\client\makepy.py to successfully generate Python sources.
> Unfortunately, after I call win32com.client.Dispatch(), the object I
> get back is of type "COMObject" instead of one of the generated
> classes.

This comes up fairly regularly, and unfortunately it depends on the object in question.

The simplest work around is to use the classes in that generated module directly.  Eg:


mod = gencache.EnsureModule('{000C1092-0000-0000-C000-000000000046}',1033, 1, 0)

i = mod.WhateverTheClassNameIs()

And to make life more painful:

>>>> db = i.OpenDatabase("d:\\temp\\test.msi", 0)

Will need to done like:

db = i.OpenDatabase("d:\\temp\\test.msi", 0)
db = mod.Database(db) # Assuming "Database" is the class name

Mark.




More information about the Python-list mailing list