Hi, I have several classes that I would like to map to COM objects to make them accessible from Excel via COM.
I have looked at the COM server interp.py supplied as example in the win32all package and I can access it easily from Excel. Now, if I add a new class Foo class Foo: def test(self): return 4 and a new funcion in this Interpreter class like def return_foo(self): return Foo() when I call from Excel the function return_foo() on the object Python.Interpreter, I get in the "Python trace collector" an exception: in _Invoke_ with 1002 1033 3 (4,) pythoncom error: Python error invoking COM method. exceptions.TypeError: Objects for SAFEARRAYS must be sequences (of sequences), or a buffer object. Evidently, Foo is not a COM Object. So how do I make it a COM Object ? I can register a new COM server "Python.Foo" and use def return_foo(self): return win32com.client.Dispatch("Python.Foo") but then: a) anybody could create it while I only want Python.Interpreter to do that b) it is not very elegant :-) So, is it possible to create new COM objects that map Python classes automatically ? Do they need to register ? Any example to advise ? BTW, why is not there a COMServer class in win32all that could enjoy metaclass facilities and inheritance to ease the work (I agree it is already quite easy but ...) ? Is it for historical reasons or is there a deep explanation ? tx Seb ps: could you reply to my address as I am not subscribed to the mailing list ? _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32