I am automating PowerPoint. Everything used to work, but now if I instantiate PPT in one thread I cannot get its name and slidecount in another thread, even after calling pythoncom.CoInitialize().
Thread 1:
pythoncom.CoInitialize()
self.pptApp = win32com.client.Dispatch("PowerPoint.Application")
Thread 2(some time later):
pythoncom.CoInitialize()
print "name", self.pptApp.ActivePresentation
Note that if I run the code in Thread2 on initial thread, it works. Otherwise as above it throws this error:
self.activePres = self.pptApp.ActivePresentation
File "C:\Python26\Lib\site-packages\win32com\client\dynamic.py", line 505, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
com_error: (-2147220995, 'Object is not connected to server', None, None)