Python COM vs Visual Basic COM

Kendall Dugger kwd at lawcomputing.com
Fri Sep 3 12:31:04 EDT 2004


I have to use an ultra simple call to a couple of
WordPerfect COM functions.

This works in Visual Basic as follows:

    Dim objWP As Variant
    Dim DocSumString As Variant
    Set objWP = CreateObject("WordPerfect.PerfectScript")
    objWP.FileOpen "c:\zebra.wpd", 1
    DocSumString = objWP.DocSumGet(18)
    Me!Text1 = DocSumString

This opens a WordPerfect file and grabs the 'Descriptive
Type' field from the document summary as a string.  Pretty
simple.

Here is almost Identical Python Code:

import win32com.client
objWP =
win32com.client.Dispatch("WordPerfect.PerfectScript")
objWP.FileOpen("c:\\zebra.wpd", 1)
DocSumString = objWP.DocSumGet(18)


When I run it it gives me the following error:

Traceback (most recent call last):
  File "C:/python_code/getdescriptivetype.py", line 3, in
-toplevel-
    objWP.FileOpen("c:\\zebra.wpd", 1)
  File
"C:\PYTHON23\Lib\site-packages\win32com\client\dynamic.py",
line 484, in __getattr__
    raise pythoncom.com_error, details
com_error: (-2147352567, 'Exception occurred.', (61704,
'WPWIN10', 'Internal application error.', None, 0, 0), None)

I am unable to decipher what this means and am at a loss for
what to try next.

I can write my application in Visual Basic if I have to, but
I would much rather use Python.  

Any assistance will be greatly appreciated.

Thanks,

-Kendall



More information about the Python-list mailing list