Python COM server to VB interface

dsavitsk dsavitsk at e-coli.net
Sun Mar 4 16:13:47 EST 2001


I am attempting to learn to use python as a com server to a VB interface.
When i run my little example i get the following error.

Run-time error'-2147467259 (800004005)':
Unexpected Python Error: AttributeError: CreateInstance

Here is the Python end of things...

    class pyserv_test:
        _public_methods_ = [ 'AddString' ]
        _reg_progid_ = 'PyServ.Test'
        _reg_clsid_ = '{EA08AFC9-E0AA-4C9B-8E42-1170A21D59AC}'

        def AddString(self, val):
            return 'the string was: ' + str(val)

    def Register():
        import win32com.server.register
        return win32com.server.register.UseCommandLine(pyserv_test)

    if __name__=='__main__':
        print "Registering COM server..."
        Register()


and here is the relevant VB code...

    Private Sub Command1_Click()
        Dim x
        Dim y
        Set x = CreateObject("PyServ.Test")
        y = x.AddString(Text2.Text)
        Text1.Text = y
    End Sub

The error occurs on the "CreateObject" line. Does anyone know what this
might be?

Thanks,
doug





More information about the Python-list mailing list