Python COM server to VB interface

Steve Holden sholden at holdenweb.com
Mon Mar 5 06:58:49 CET 2001


"dsavitsk" <dsavitsk at e-coli.net> wrote in message
news:keyo6.156158$Ch.31627133 at newsrump.sjc.telocity.net...
> 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?
>
It may well be due to the absence on an __init__() method in your object?

regards
 Steve






More information about the Python-list mailing list