ValueError: argument is not a COM object

Stefano Masini stefano at stefanomasini.com
Tue May 18 09:10:38 EDT 2004


Hi,

I'm scripting Adobe InDesign CS with python, through COM interface.

This is how I get the application object:

  win32com.client.Dispatch('InDesign.Application')

I'm not a guru of com programming, but I've gone quite far in my
purpose so far.
Now I'm stuck.

There's a method Add in object Groups (which is in object Page, etc.)
that's supposed to take a parameter called GroupItems of type "Array
of Objects", according to the Visual Basic programming reference.

I have the following piece of code:

    print 'obj1: %r, obj2: %r' % (comObjs[0], comObjs[1])
    grps = self.page.comPage.Groups
    grps.Add( GroupItems=(comObjs[0], comObjs[1]) )

Which gives me:

obj1: <COMObject <unknown>>, obj2: <COMObject <unknown>>

[...]
  File "modPrint.py", line 204, in creaFrameLoghi
    grps.Add( GroupItems=(comObjs[0], comObjs[1]) )
  File "<COMObject <unknown>>", line 2, in Add
ValueError: argument is not a COM object


Why is it so?
I suppose the type system is having troubles figuring out the type of
the list elements.
So, what do I do?

I hope somebody can help,
thank you!
stefano



More information about the Python-list mailing list