So I have a Visual Basic script in Excel which connects via com to programX and retrieves data. The COM function takes 7 required arguments. arg1-6 are set equal to values to determine what data to fetch. arg7 is the variant in which the function returns the fetched data.
In VB it works like this: Private Function functionX(arg1 As Long, arg2 As Integer, arg3 As Long, arg4 As Long, arg5 As Boolean, arg6 As Long) As Variant Dim px As Object Dim status As Boolean Dim arg8 As Integer Dim arg9 As Integer Dim arg10 As Integer Dim arg7 As Variant Set px = GetObject("programx.activex.interface") status = px.functionX(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) If Not status Then data = "wait" End If If a = 0 And b = 0 And c = 0 Then data = arg7 The end of which the variable 'data' is set to the value returned by the com interface. So when I call the function, I get: arg1 = ... setting all arg# variables ... x1 = functionX(arg1, arg2, arg3, arg4, arg5, arg6) and x1 = the returned value When I try this in python, I get a type mismatch, for the apparent reason that arg7 is not a variant. Of course, python being the wonderful language it is, arg7 can be any type I want, whenever I want to change it.... except there is no 'variant' type because of this. >>> arg1 = .... setting all arg# variables ... >>> x1 = win32com.client.GetObject("programX.activex.interface") >>> `x1` '<COMObject programX.activex.interface>' >>> x1.FunctionX(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "<COMObject programX.activex.interface>", line 2, in FunctionX com_error: (-2147352571, 'Type mismatch.', None, 7) >>> So I'm at a loss as to how to force passing arg7 as a variant type. From what I gather in researching this, win32com.client is supposed to handle typing automagically. Somehow I'm missing something. HELP!?!?
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32