[python-win32] Why does a python COM server return different data to VBA and Python clients?

jeffwelch at earthlink.net jeffwelch at earthlink.net
Mon Apr 9 19:40:05 CEST 2012

My apologies to the list about my earlier question that was in html. My webmail is supposed to default to plain text but clearly did not.

I am trying to write a Python server that will be used by a C++ client. It has taken me quite a while longer than I expected. I have been through the archives and that helped me get to where I am. Many thanks to all those who support these packages.

I am using Python 2.5.1 as it is required by some vendor equipment that I must use.

One of the reasons it took me a while to get this going was that I was trying to test it in Python. Once I switched to testing it in VBA then I made much faster progress.

For demonstration purposes I used the Pippo test in the 'win32com\test' directory. I modified the testpippo.py by adding some code at the start of the testLeaks method. I added the 4 lines:

        in1 = 15
        inout1 = 99
        hr= self.object.Method3( in1, inout1)
        print hr, "retval = %d inout1 = %d"%(hr[0], hr[1])

The printed line was "(0, -31) retval = 0 inout1 = -31".

I get "retval = -41 inout1= -31"  if I execute the VBA code:

Sub TestPippo()
    Dim obj As Pippo
    Dim in1 As Long
    Dim inout1 As Long

    Set obj = CreateObject("Python.Test.Pippo")
    in1 = 1
    inout1 = 2
    retval = obj.Method3(in1, inout1)
    MsgBox ("retval = " & retval & " inout1 = " & inout1)
End Sub

Is there a way to call the same Python Server Method, Method3, so that both Python and VBA receive the same return data?


More information about the python-win32 mailing list