Hello, I am trying to automate the commercial software "CST Microwave Studio" using win32com, on a 32 bit windows XP machine. The program has a reasonably well documented COM interface, and for example I am able to run the following .vbs script, which shows the expected behaviour of opening a new project and doesn't return any error messages:
Set app = CreateObject ("CSTStudio.Application") Set mws = app.NewMWS However, vbscript is far too primitive for what I want to do, so I have translated this code to python using win32com: import win32com.client cst = win32com.client.Dispatch("CSTStudio.Application") cst.NewMWS() This results in the following error output: Traceback (most recent call last): File "C:\Documents and Settings\dap124\Desktop\cst_com.py", line 19, in <module> cst.NewMWS() File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 508, in __getattr__ return self._get_good_object_(ret) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 301, in _get_good_object_ return self._get_good_single_object_(ob) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 289, in _get_good_single_obj ect_ return self._wrap_dispatch_(ob, userName, ReturnCLSID) File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 125, in _wrap_dispatch_ return Dispatch(ob, userName, returnCLSID,None) File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx) File "C:\Python25\Lib\site-packages\win32com\client\__init__.py", line 43, in __WrapDispatch return dynamic.Dispatch(dispatch, userName, WrapperClass, typeinfo, clsctx=clsctx) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 121, in Dispatch typecomp = typeinfo.GetTypeComp() AttributeError: 'NoneType' object has no attribute 'GetTypeComp' >>> This seems to happen regardless of which version of pywin32 I use, or whether I run it from ipython, or the normal python console. It does actually perform the desired action of opening a new project in the CST program, and it seems that the error has something to do with the returned value which I need for further communication over the COM interface. I also tried using the comtypes package, which results in the following code: Set app = CreateObject ("CSTStudio.Application") Set mws = app.NewMWS This results in the following error output: Traceback (most recent call last): File "C:\Documents and Settings\dap124\Desktop\cst_com.py", line 23, in <module> cst.NewMWS() File "C:\Python25\Lib\site-packages\comtypes\client\dynamic.py", line 95, in __getattr__ result = self._comobj.Invoke(dispid, _invkind=flags) File "C:\Python25\Lib\site-packages\comtypes\automation.py", line 699, in Invoke return result._get_value(dynamic=True) File "C:\Python25\Lib\site-packages\comtypes\automation.py", line 349, in _get_value return Dispatch(ptr) File "C:\Python25\Lib\site-packages\comtypes\client\dynamic.py", line 28, in Dispatch tinfo = obj.GetTypeInfo(0) File "C:\Python25\Lib\site-packages\comtypes\automation.py", line 599, in GetTypeInfo return result.QueryInterface(comtypes.typeinfo.ITypeInfo) File "C:\Python25\Lib\site-packages\comtypes\__init__.py", line 1069, in QueryInterface self.__com_QueryInterface(byref(iid), byref(p)) ValueError: NULL COM pointer access >>> Does anyone have any suggestions as to why python is failing here? I appreciate that it is hard to know what a closed source program is doing with it's interface, but if anyone understands anything from the above error messages which may help me, then I would be most appreciative regards David _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32