Need help with COMObject for Zope

Mark Hammond mhammond at skippinet.com.au
Wed Apr 26 20:49:55 EDT 2000


<deepak_marda at my-deja.com> wrote in message
news:8e7jeo$s8c$1 at nnrp1.deja.com...

> I created a COMObject with id = word and Dispatch
> = "Word.Application". WHen I try to connect this
> COM object, it raises the following exception
> Error Type: com_error
> Error Value: (-2147221008, 'CoInitialize has not
> been called.', None, None)

Add the 2 lines:
import pythoncom
pythoncom.CoInitialize()

before your code, and it will almost certainly work.

The Zope guys should document this fairly well.  Note that Zope is almost
certainly initializing COM on a different thread than your code is being
called on (hence you see this message) - but there are some serious
implications with COM and threading.  I dont believe you will hit them
here, but someone will sometime :-)

Mark.






More information about the Python-list mailing list