1

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)
Tim D
  • 1,645
  • 1
  • 25
  • 46
Radu
  • 2,076
  • 2
  • 20
  • 40
  • For other issues with multithreading and win32gui, I ended up using another library instead of win32gui. ctypes to be exact - it works better from a 'secondary' (may be daemon) thread. – Radu Feb 06 '13 at 08:16

0 Answers0