- Found word(s) list error in the Text body - [Python-au] PythonCom Error

Grant McDonald gmcdonald at
Thu Feb 10 03:46:33 CET 2005

My guess is that since a tuple is a python object and not a SAFEARRAY the
types are incompatible and hence no translation occurs.  You probably have
to insert it element by element. Be aware this is only an educated guess.

-----Original Message-----
From: Christian Daldrup [mailto:Christian.Daldrup at] 
Sent: 09 February 2005 22:21
To: python-au at
Subject: gmcdonald at - Found word(s) list error in the Text body
- [Python-au] PythonCom Error


I am new in this mailing list and so first greetings to all users.

I have written a C++ Com Dll (VS 6). In this Dll I declared a struct 
with a SafeArray(double) as a member.

My IDL implementation:
    helpstring("Parameters for Lib") 
struct Params { 
    [helpstring("Distribution")] long lDistribution; 
    [helpstring("Type")] long lType; 
    [helpstring("a CalFlag")] long  lACalFlag; 
    [helpstring("b CalFlag")] long lBCalFlag; 
    [helpstring("c CalFlag")] long lCCalFlag; 
    [helpstring("d CalFlag")] long lDCalFlag; 
    [helpstring("a")] double dA; 
    [helpstring("b")] double dB; 
    [helpstring("c")] double dC; 
    [helpstring("d")] double dD; 
    [helpstring("q")] double dQ; 
    [helpstring("ks")] SAFEARRAY(double) dKs; 
} Params; 

First I created a file with
Standard variables like "dA" I can set normally:
import win32com.client
myCom = win32com.client.Dispatch("ComLib.Lib")
rec = win32com.client.Record('Params', myCom)
rec.dA = 3.5 # works fine
rec.dKs = (1.0, 2.0, 3.0 ,4.2, 5.5) # doesn?t work
Error Message:
Traceback (most recent call last): 
File "C:\Visual Studio 6.0\", line 6, in ? 
myStruct.dKs = (1,2,3,4) 
pywintypes.com_error: (-2147024809, 'Falscher Parameter.', None, None)

After this I try to use an array:
import array
a = array.array('d', [1.4, 3.4])
b = buffer(a)
rec.dKs = b
# same error

In VBA I use the same struct, but their I ReDim the SafeArray:
Dim vp As Lib.Params
ReDim vp.dKs(UBound(params, 1))
Call Range2DblArray(params, vp.dKs)

# my vba fill function
Sub Range2DblArray(range As Variant, arr As Variant)
    'ReDim myArray(UBound(range, 1))
    Dim i As Integer
    For i = 1 To UBound(range, 1)
        arr(i) = CDbl(range(i, 1))
    Next i
    'Range2Array = myArray
End Sub

In VB the Code works fine.

Now, I'd like to know, if it is possible to create/resize the dKs tuple in
the com_struct or if I have to implement a function in my DLL which adds
elements to my struct in the DLL?

thank you in advance


DSL Komplett von GMX +++ Supergunstig und stressfrei einsteigen!
AKTION "Kein Einrichtungspreis" nutzen:

python-au maillist  -  python-au at
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the python-au mailing list