COM question

Benoit Goudreault-Emond postmaster at 127.0.0.1
Tue May 2 11:23:24 EDT 2000


In article <390E1B0E.D973BEEF at world.std.com>, David Lees wrote:
> Yes you are correct about the version.  You imply that something has to
> have VBA for me to be able to talk to it using Python?  I thought I
> could start up word from Python by just knowing it's COM name?  In fact,
> I can find the CLSID in the registry, but have no idea how to use that
> in place of "word.application".
> 
> Anyway, I installed python on my new machine which has Word 2000 and
> have no problem getting the
> win32com.client.Dispatch("Word.Application") example to work with it.
> 
> David Lees

No, I'm implying only that the interface you'll see from Python for Word 7.0
is very different from the VBA interface exposed by Word 8.0+.  You *can*
start word from Python by knowing its COM name; the thing is, the COM name
is different AFAIK. (I'll have to hunt the registry to figure out the right
name, but I'm under Linux now, so you'll have to wait for me to reboot :{) )

The COM name should be something like Word.WordBasic or something similar.
Or it may even be word.application, I'm not too sure; the point is, your
example won't work because the interface is totally different from the one
expected by the example.  IOW, you'll be able to get the handle on the
interface, but anything you do after that will have to be coded differently.

Such are the joys of COM. :{)

BTW, to get the name from the CLSID:

- open regedit
- Go to \\HKEY_CLASSES_ROOT\{your CLSID}
- In the right pane, you should see the actual name (Word.Application or
  otherwise) as the key's value.
- You can then scroll down to \\HKEY_CLASSES_ROOT\Word.Application and
  you'll see a lot of interesting things (where the object is found by the
  system, etc).

-- 
Benoit Goudreault-Emond
CoFounder, KMS Group ; Student, B. Comp. Eng, Concordia University
``Being too close to a fireball can worry a man --- to death.''
        -- Zeb Carter in "The Number of the Beast" by Robert A. Heinlein

Note:   the "From:" address is not correct to protect myself against spam.
        My actual e-mail address is: ``bge AT crosswinds DOT net''



More information about the Python-list mailing list