[python-win32] Having more Excel troubles.

Mark Hammond mhammond at skippinet.com.au
Thu Aug 26 06:06:50 CEST 2004


> _GetGoodDispatchAndUserName
>      Module win32com.client.dynamic, line 79, in _GetGoodDispatch
>      com_error: (-2147221008, 'CoInitialize has not been
> called.', None,
> None)

That error means "CoInitialize has not been called *on this thread*".  Try
calling pythoncom.CoInitialize() at the top of your script - it should not
throw an error if it has already been called.

I'm not sure this is a great idea though - you would be better off creating
your own thread that processes *all* excel requests, possibly using the
queue module.  Consider what will happen when 2 people try and perform the
conversion at the same time.  By using DispatchEx() you can force each
thread to get its own Excel, but I'm not sure that is a great idea even
then.

Mark



More information about the Python-win32 mailing list