Registered COM object not recognized by python's win32com.client.dispatch()

com, python, win32com

Solution

Fixed this problem by installing Python 64 bit and win32com 64 bit.

Problem

I'm trying to load a COM object with Python. I'm using win32com.client.Dispatch("Name.Of.Object") to load it, and the COM object has been registered with regsvr32 and appears as an entry in my registry in both HKLM/CLSID and HKLM/Wow6432Node/CLSID. I can open it using VBScript just fine, but Python's win32com.client.Dispatch() gives me this error: ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 108, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 85, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221164, 'Class not registered', None, None) ``` I have read that there are issues with 32 vs 64 bit; I'm running this on a 64-bit machine using 32-bit python and 32-bit win32com. Any suggestions? Note that this code in VBScript works fine: ``` Set obj = WScript.CreateObject( "Name.Of.Object" ) ``` Thanks

Original source