win32com.client.Dispatch returns CLSID different than makepy

Markus Wankus markus_wankusGETRIDOFALLCAPS at hotmail.com
Sat Mar 6 11:45:06 EST 2004


This sounds like a problem I ran into that I was never able to figure
out either.  Mark Hammond says there is nothing that can be done about
it, but if you jump through some manual hoops you may be able to get it
to work.

For more info, Google for "solidworks python win32com" in the Google
"groups", and click the first hit you get.  Or, if you don't mind long 
URL's:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=solidworks+python+win32com&sa=N&tab=wg

HTH.
Markus

Stefano Masini wrote:
> I'm trying to script Adobe InDesign CS from python thru COM, and I'm 
> having a horrible time to even get started.
> 
> I ran makepy, and chose "Adobe InDesign CS Type Library". It produced
> a horribly named module inside the gen_py directory, and when I run
> gencache.py -d I get this:
> 
> Cache is in directory C:\Python23\lib\site-packages\win32com\gen_py 
> Adobe InDesign CS Type Library - 
> {6926C15F-E97E-4b13-8658-A97D8C616945}
> 
> Therefore it looks like everything worked so far, and the type
> library for InDesign has the Class ID
> {6926C15F-E97E-4b13-8658-A97D8C616945}
> 
> Now, when I write the following python code:
> 
> comApp = win32com.client.Dispatch('InDesign.Application') print
> repr(comApp)
> 
> I get:
> 
> <COMObject InDesign.Application>
> 
> Which looks like a dynamic dispatch, rather that a static one, as it 
> should be since I ran makepy on purpose.
> 
> Indeed, I manually placed some print statements around the win32com 
> python source code and I figured out that the name 
> 'InDesign.Application' (I also tried with 'InDesign.Application.CS') 
> maps to the Class ID {ABD4CBB2-0CFE-11D1-801D-0060B03C02E4}. This is
> different from the one produced by makepy, and therefore the dispatch
> method can't find anything in cache, and falls back to dynamic
> behaviour.
> 
> Anybody have a clue on what's going on here?
> 
> I thought I ought to write something different that 
> 'InDesign.Application'... so I tried 'Adobe.InDesign.Application', 
> 'Adobe.CS.....' and all sorts of things, but no luck.
> 
> Once I chose the 'Adobe InDesign CS Type Library' from makepy, how do
>  I know what am I supposed to use as the parameter to Dispatch() ?
> 
> Thank you very much, I hope somebody helps me out. Maybe with some
> useful readings...



More information about the Python-list mailing list