Win32com

Volucris volucris at hotmail.com
Mon Jul 2 16:15:26 EDT 2001


This is the code I used and it worked fine. Maybe you could post more code.

***Begin VB Code***

Private Sub Form_Load()
    Set PyObj = CreateObject("PythonComTest.TestClass")
    MsgBox PyObj.SomeMethod
End Sub

***End VB Code***


***Begin Python Code***

class PythonCOMTest:
    _public_methods_ = [ 'SomeMethod']
    _reg_progid_ = "PythonComTest.TestClass"
    _reg_clsid_ = "{41E24E95-D45A-11D2-852C-204C4F4F5020}"
    def SomeMethod(self):
        return "Hello!"

if __name__ == '__main__':
    print "Registering COM server..."
    import win32com.server.register
    win32com.server.register.UseCommandLine(PythonCOMTest)

***End Python Code***

--

Volucris (a) hotmail.com
"Eu não falo uma única palavra do português."


"Mamoon Khan" <mamoonk at nortelnetworks.com> wrote in message
news:mailman.994082583.16562.python-list at python.org...
> I am trying to create a ComServer .  Following is some part of the code
that
> you guys need to see if I am doing it right.
>
> _public_methods_ = [ 'SomeMethod']
> _reg_progid_ = "PythonComTest.TestClass"
> _reg_clsid_ = "{41E24E95-D45A-11D2-852C-204C4F4F5020}"
>
> Here the vb code that I am using
>
> Dim SomeServer as Variant
> Set SomeServer = CreateObject(PythonComTest.TestClass")
>
> msgbox SomeServer.SomeMethod()
>
>
> I can register the Com Server fine and can call it from within python
using
> createobject no problem.
>
> When I go to use it from VB I can create an object SomeServer fine but
when
> I call a method and return a string from a function and try to display the
> results in a message box, I get an error invalid type.
>
> Could someone tell me what the heck is going on here with this.
>
> TIA
>
> Mamoon
>
>





More information about the Python-list mailing list